Search
⌘K

Leetcode 1326. Minimum Number of Taps to Open to Water a Garden

Given n and ranges for taps at positions 0..n (each tap i covers [i - ranges[i], i + ranges[i]]), find the minimum number of taps whose intervals together cover the entire segment [0, n], or return -1 if impossible. This is an interval-cover/jump-game style problem solvable by greedily selecting the interval with the farthest right reach at each step.


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.