i
representing the end of the current window.k
, contract the window from the left by incrementing the start index and decrementing the count of ones if a '1' is removed.k
, compare the current window's length and lexicographic order with the result.