#3489
Zero Array Transformation IV
expert · 1120 · lc medium +32 · 31% accepted · 142 likes · top 8%
Description
Array nums of length n and operations queries[i] = [li, ri, vali] are given. Each operation lets you subtract vali from any chosen subset of indices in [li, ri].
Find the smallest k >= 0 such that applying the first k operations can reduce every element of nums to zero. Return -1 if it is impossible.
Code
1
2
3