3362. Zero Array Transformation III
You are given an integer array
nums
of lengthn
and a 2D arrayqueries
wherequeries[i] = [li, ri]
.Each
queries[i]
represents the following action onnums
:
- Decrement the value at each index in the range
[li, ri]
innums
by at most 1.- The amount by which the value is decremented can be chosen independently for each index.
A Zero Array is an array with all its elements equal to 0.
Return the maximum number of elements that can be removed from
queries
, such thatnums
can still be converted to a zero array using the remaining queries. If it is not possible to convertnums
to a zero array, return -1.
1 | class Solution { |