1326. Minimum Number of Taps to Open to Water a Garden
Last updated
Last updated
**Input:** n = 5, ranges = [3,4,1,1,0,0]
**Output:** 1
**Explanation:** The tap at point 0 can cover the interval [-3,3]
The tap at point 1 can cover the interval [-3,5]
The tap at point 2 can cover the interval [1,3]
The tap at point 3 can cover the interval [2,4]
The tap at point 4 can cover the interval [4,4]
The tap at point 5 can cover the interval [5,5]
Opening Only the second tap will water the whole garden [0,5]**Input:** n = 3, ranges = [0,0,0,0]
**Output:** -1
**Explanation:** Even if you activate all the four taps you cannot water the whole garden.**Input:** n = 7, ranges = [1,2,1,0,2,1,0,1]
**Output:** 3**Input:** n = 8, ranges = [4,0,0,0,0,0,0,0,4]
**Output:** 2**Input:** n = 8, ranges = [4,0,0,0,4,0,0,0,4]
**Output:** 1