• + 0 comments

    By using stack u can solve it in O(n) time. Here there is concept similar to find the smallest window in a string to find a pattern containg fixed count of some characters. here max iteration time is O(2*n)=O(n).