3362. Zero Array Transformation III
You are given an integer array
numsof lengthnand a 2D arrayquerieswherequeries[i] = [li, ri].Each
queries[i]represents the following action onnums:
- Decrement the value at each index in the range
[li, ri]innumsby 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 thatnumscan still be converted to a zero array using the remaining queries. If it is not possible to convertnumsto a zero array, return -1.
1 | class Solution { |