Sliding Window

If the window is valid, expand right.
Else, shrink left.

O(n)

Python | Java

Maintain a valid window at the end of each outer for loop
to find the longest subsequence.

LeetCode

1493. Longest Subarray of 1's After Deleting One Element

Python | Java

Next
Next

Leftmost Binary Search