Search
⌘K

Leetcode 3356. Zero Array Transformation II

Given range queries that can decrement each index in their range by up to val independently, find the smallest prefix length k such that for every index the total available decrement from the first k queries covering that index is at least nums[i] (otherwise return -1). Key challenge: efficiently test prefixes — typically solved by binary searching k and using a difference/prefix-sum array (or segment tree) to accumulate query contributions.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.