Leetcode, Interval, Interview Questions, Google, Meta.
range [i-A[i], i+A[i]], there are 2 possible situations: The i-th tap is opened The i-th tap is not opened If the i-th tap is opened, then we can close all taps which already waters within the region [i-A[i], i+A[i]]. Maintain a stack S of open taps. When a tap is added to the stack of open taps,