Reported September 2026
Googleprefix sum

Zero Array Transformation I

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 kills the naive solution on this Google problem, reported in September 2026, is simulating each query by looping over its range. With 10^5 queries and 10^5 indices, that's a timeout waiting to happen. Zero Array Transformation I is an array problem with a difference-array trick hiding inside. You don't pick subsets. You just count how many queries cover each index. If you're taking this OA in the next couple of days, learn that one idea cold. StealthCoder sits invisibly on your screen as a safety net in case you blank mid-assessment, but the idea is small enough to own yourself.

The problem

You are given an integer array nums and a list of inclusive index ranges queries. Each query has the form [left, right].
Process the queries in order. For each query, you may choose any subset of indices between left and right, inclusive, and decrement the value at every chosen index by 1. You may choose a different subset for every query.
Return true if all values in nums can be made exactly 0 after all queries are processed. Otherwise, return false.

Function
isZeroArray(nums: int[], queries: int[][]) → boolean

Examples
Example 1
nums = [1,0,1]
queries = [[0,2]]
return = true
The only query covers the whole array. Decrement indices 0 and 2; index 1 is already zero.
Example 2
nums = [4,3,2,1]
queries = [[1,3],[0,2]]
return = false
Index 0 is covered only once, so its value can decrease from 4 to at best 3. Reaching an all-zero array is impossible.

Constraints
1 <= nums.length <= 10^5.
0 <= nums[i] <= 10^5.
1 <= queries.length <= 10^5.
queries[i].length == 2.
0 <= queries[i][0] <= queries[i][1] < nums.length.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Each index i can be decremented at most once per query that covers it. Since you choose any subset per query, index i can drop by anywhere from 0 up to cover[i]. So the answer is true exactly when nums[i] <= cover[i] for every i. No greedy, no DP. Compute cover with a difference array: for each [l, r], add 1 at diff[l] and subtract 1 at diff[r+1]. Then take a running prefix sum and compare against nums. That's O(n + q). The common pitfall is the brute-force range loop, which is O(n*q). The other slip is the diff array size. Allocate n+1 so r+1 doesn't overflow when r = n-1. Also remember nums[i] = 0 always passes, even with zero coverage. If your mind goes blank on the live OA, StealthCoder can surface the difference-array solution quickly, but know the coverage check first.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Zero Array Transformation I 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 by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as zero array transformation i. If you have time before the OA, drill that.

⏵ The honest play

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

Google reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Zero Array Transformation I FAQ

What's the trick in Zero Array Transformation I?+

Stop thinking about subsets. Each query lets you decrement any index in its range by at most 1, so the max total decrement at index i equals the number of queries covering it. Check nums[i] <= coverage[i] for all i. Coverage comes from a difference array plus a prefix sum.

Why does the brute force fail?+

Looping over every index in every query is O(n*q). With both up to 10^5, that's around 10^10 operations in the worst case. The difference array reduces range updates to O(1) each, then one pass builds coverage. Total work is linear.

What edge cases should I test?+

Test nums that are all zeros, which is always true. Test a query ending at the last index, which needs the diff array sized n+1. Test an index covered by no query with a positive value, which must return false. Also try a single-element array.

Is this pattern still asked by Google?+

It was reported as a Google OA in September 2026, so yes, it's current. Range updates via difference arrays and prefix sums show up often in array questions. Knowing this one technique covers many variants, including ones where queries are applied progressively.

How do I prepare in 48 hours?+

Write the difference array solution from scratch twice without looking. Then try a variant where you must find the smallest number of queries needed. That version uses binary search on the same coverage check. Skip broad grinding. This one pattern is worth the time.

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