PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Determine Whether Queries Can Zero Array

Last updated: May 3, 2026

Quick Overview

This question evaluates competency in array manipulation, range updates, and feasibility under constraints, focusing on reasoning about sequential interval operations and per-index decrement decisions while maintaining non-negativity.

  • medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Determine Whether Queries Can Zero Array

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given an integer array `nums` of length `n` and a list of range operations `queries`, where each query is of the form `[l, r, val]`. Process the queries in the given order. For each query `[l, r, val]`, you may independently choose, for every index `j` such that `l <= j <= r`, to decrease `nums[j]` by any integer amount from `0` to `val`, inclusive. Requirements: - The chosen decrease for each index in the range may be different. - After every operation, all values in `nums` must remain non-negative. Return `true` if it is possible to make every element of `nums` equal to `0` after processing all queries. Otherwise, return `false`. Example: - Input: `nums = [1, 0, 1]`, `queries = [[0, 2, 1]]` - Output: `true` - Explanation: In the only query, decrease index `0` by `1`, index `2` by `1`, and leave index `1` unchanged. The array becomes `[0, 0, 0]`.

Quick Answer: This question evaluates competency in array manipulation, range updates, and feasibility under constraints, focusing on reasoning about sequential interval operations and per-index decrement decisions while maintaining non-negativity.

Related Interview Questions

  • Thread-Safe Token-Bucket Rate Limiter - Uber
  • Quadtree for 2D Geospatial Points - Uber
  • Group Anagrams - Uber
  • Deep Equality of Two Records - Uber (medium)
  • Shortest Path in a Grid with Blocked Cells - Uber (medium)
|Home/Coding & Algorithms/Uber

Determine Whether Queries Can Zero Array

Uber logo
Uber
Apr 17, 2026, 12:00 AM
mediumSoftware EngineerOnsiteCoding & Algorithms
3
0
Practice Read
Loading...

You are given an integer array nums of length n and a list of range operations queries, where each query is of the form [l, r, val].

Process the queries in the given order. For each query [l, r, val], you may independently choose, for every index j such that l <= j <= r, to decrease nums[j] by any integer amount from 0 to val, inclusive.

Requirements:

  • The chosen decrease for each index in the range may be different.
  • After every operation, all values in nums must remain non-negative.

Return true if it is possible to make every element of nums equal to 0 after processing all queries. Otherwise, return false.

Example:

  • Input: nums = [1, 0, 1] , queries = [[0, 2, 1]]
  • Output: true
  • Explanation: In the only query, decrease index 0 by 1 , index 2 by 1 , and leave index 1 unchanged. The array becomes [0, 0, 0] .

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.