dsa1 min read
Count Number of Nice Subarrays [Medium] — atMost(k)−atMost(k−1)
Count subarrays with exactly k odd numbers using the at-most(k) minus at-most(k-1) sliding window formula.
Read →
1575 articles
Count subarrays with exactly k odd numbers using the at-most(k) minus at-most(k-1) sliding window formula.
Count binary subarrays with exactly the given sum using prefix sum with HashMap or the atMost(k)-atMost(k-1) trick.
Find the maximum frequency of any element after at most k increments by sorting and using a sliding window with a running sum.
Find minimum operations to reduce X to zero from either end by finding the longest middle subarray with sum = total-X.
Find the longest mountain subarray (strictly increasing then decreasing) using two separate forward scans for up and down slopes.