3355. Zero Array Transformation I

Practice Zero Array Transformation I for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

You are given nums and a list of queries[i] = [l, r]. Process the queries in order; for each one, choose any subset of indices in [l, r] (inclusive) and decrease the value at each chosen index by 1.

Return true if you can make every element of nums equal to 0 after all queries, otherwise false.

Example

nums = [1,0,1], queries = [[0,2]]              ->  true
nums = [4,3,2,1], queries = [[1,3],[0,2]]      ->  false

Constraints