Zero Array Transformation II

You are given an integer array nums of length n and an array queries, where queries[j] = [l_j, r_j, val_j].

Process queries in order. When you apply a query [l, r, val], for every index i in the inclusive range [l, r] you may independently decrement nums[i] by any integer amount in [0, val] (possibly different amounts at different indices, and possibly 0).

Return the minimum number of queries k (a prefix length, so you use the first k queries in order) such that it is possible to make every element of nums equal to 0. If nums is already all zeros, return 0. If it is impossible even after using all queries, return -1.

Examples
Input: [[2,0,2],[[0,2,1],[0,2,1],[1,1,3]]]
Output: 2
Hints
Related Problems

Zero Array Transformation II

You are given an integer array `nums` of length `n` and an array `queries`, where `queries[j] = [l_j, r_j, val_j]`.