Solution: Zero Array Transformation III
C# solution for the Zero Array Transformation III problem using the Greedy Techniques pattern.
We'll cover the following...
Statement
You are given an integer array nums and a list of range queries queries, where each query is a pair [l_i, r_i].
If you keep a query [l_i, r_i], you may apply it at most once. Applying it lets you choose, independently for every index j in the range l_i \leq j \leq r_i, how much to decrement nums[j] by, as long as the decrement is an integer and the total decrement at j across all kept queries does not exceed the original value of nums[j].
Your goal is to remove as many queries as possible while still being able to turn nums into an all zero array using the remaining queries. Return the maximum number of queries you can remove. If it is impossible to make nums all zeros even after keeping all queries, return
Note: Each kept query contributes at most
unit of decrement capacity to each index in its range, and you may distribute that capacity across indices independently.
Constraints:
...