Google·Software Engineer·Onsite - Coding / Algorithms
- You're given an integer array and a list of range-assignment queries, each specifying a start index, end index, and value to assign across that range. Queries are applied in order, so later ones overwrite earlier ones on overlapping positions. Return the final array. The naive O(n * q) solution is too slow. What's a more efficient approach?
“My first instinct was just to simulate it, which is obviously wrong at scale.”