Skip to content

Practice Zero Array Transformation I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3355
LeetCode Problem

Zero Array Transformation I

Problem Statement

Process each inclusive query [l, r] by choosing any subset of indices in that interval and decreasing each selected value in nums by 1. Different indices may be selected in different queries, and a subset may be empty. Return whether choices exist that make every value zero after all queries have been processed in order.

Source: Zero Array Transformation I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,0,1], queries = [[0,2]]
Output
true

# Example 2

Input
nums = [4,3,2,1], queries = [[1,3],[0,2]]
Output
false

Constraints

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

Related LeetCode Problems

Practice more problems similar to Zero Array Transformation I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.