Reported October 2026
Googlearray

Running Interval Union Length

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

The edge case that breaks the naive answer here is an upload that lands inside space you already covered, or one that bridges several intervals at once. Google reported this one in October 2026, and it reads like an easy array problem until your running total drifts. Intervals are half-open, they arrive one at a time, and you return the total covered length after each upload. Take [1,5],[7,10],[3,8],[8,9], which gives [4,7,9,9]. That last upload adds zero, and that's the case people miss. If you blank during the live OA, StealthCoder runs invisibly on your screen and hands you a working solution to check against.

The problem

Intervals arrive one at a time in uploads. Each row [left, right] represents the half-open interval [left, right).

Examples
Example 1
uploads = [[1,5],[7,10],[3,8],[8,9]]
return = [4,7,9,9]
The first two intervals cover lengths 4 and 3. Uploading [3,8) joins them into [1,10), whose length is 9. The final interval is already covered.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to keep a sorted list of disjoint intervals plus a running total. For each new [l, r), binary search for the first stored interval whose end is at least l. Walk forward while stored starts are at most r. For each one you absorb, subtract its length from the total and widen l and r to cover it. Then insert the merged interval and add its length. Contained uploads absorb one interval and re-add the same length, so the total doesn't change. The pitfall is re-merging every interval after each upload. That's O(n^2 log n) and times out on big inputs. The other trap is off-by-one on touching intervals. With half-open ranges, [3,8) and [8,9) touch but don't overlap, so merging them is safe and the length math still works. If the live OA freezes your brain, StealthCoder is the hedge.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Running Interval Union Length cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Running Interval Union Length FAQ

How hard is the Running Interval Union Length problem really?+

It's medium. The idea is simple, but the bookkeeping is where people lose points. You have to handle contained, overlapping, touching and bridging intervals with one consistent rule. If you can merge intervals on paper, you can solve this. The risk is a sloppy total that breaks on the fourth example.

What's the trick to getting the running length right?+

Don't recompute the union from scratch. Keep disjoint sorted intervals and a total. When a new interval absorbs old ones, subtract their lengths, merge, then add the merged length. A fully covered upload nets zero change, which matches the 9 to 9 step in the example.

Do touching intervals like [3,8) and [8,9) need special handling?+

Not really. Half-open means they share no points, so no length is double counted. Merging them into [3,9) or leaving them separate gives the same total. Just pick one rule, usually merge when stored start is at most the new right, and apply it everywhere.

What complexity should I aim for?+

Aim for O(log n) to find the position plus the number of intervals absorbed. Each interval is absorbed at most once, so total work is amortized well. A plain list with bisect is fine for an OA. A brute-force re-merge per upload is the version that gets flagged as too slow.

How do I prepare for this in 48 hours?+

Write the merge-and-insert routine from memory twice. Then test four cases: disjoint, overlapping, fully contained, and bridging multiple intervals. Run the Google example by hand and confirm you get [4,7,9,9]. Practice similar interval-merging problems so the sorted-list pattern feels automatic when the timer starts.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it