FastPrepZero Array Transformation I
Problems/Zero Array Transformation I

Zero Array Transformation I

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names a well-known problem, Zero Array Transformation I. Our version is about 99% the same as it.

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.

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
  • Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Earliest Time to Schedule a MeetingMicrosoft · OAMicrosoft interview questions
  • Earliest Common Meeting StartVisa · OAVisa interview questions
  • Smallest Most-Lit Street PositionHudson River Trading · OAHudson River Trading interview questions
  • Most Visited Sprint MarkerChubb · OAChubb interview questions
  • Earliest Common Meeting TimeZipRecruiter · OAZipRecruiter interview questions
  • File Download Coverage PercentagePersona · OAPersona interview questions

Interview reports that mention this question

  • Google SWE Intern Interviews: 85 Experiences (Part 1 of 8)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean isZeroArray(int[] nums, int[][] queries) {
        // Write your code here.
    }
}
Checking account…