dsa1 min read
Max Consecutive Ones [Medium] — K-Flip Sliding Window
Find the maximum consecutive ones in a binary array when you can flip at most k zeros, identical to the Max Consecutive Ones III pattern.
Read →
webcoderspeed.com
1276 articles
Find the maximum consecutive ones in a binary array when you can flip at most k zeros, identical to the Max Consecutive Ones III pattern.
Sort only the vowels in a string while keeping consonants in place by extracting vowels, sorting, then reinserting.
Find the minimum window in s that contains t as a subsequence by using a forward pass to find a valid window then backward pass to minimize it.
Count subarrays where the median is exactly k by converting the problem to counting balanced prefix sequences around k.
Find the median of each sliding window of size k using two heaps (max-heap for lower half, min-heap for upper half) with lazy deletion.