dsa1 min read
Minimum Consecutive Cards to Pick Up [Medium] — HashMap Window
Find the minimum number of consecutive cards that contain a matching pair using a HashMap tracking last seen positions.
Read →
1575 articles
Find the minimum number of consecutive cards that contain a matching pair using a HashMap tracking last seen positions.
Count subarrays where score = sum × length is less than k using a shrinkable sliding window with running sum.
Find the smallest window in s containing all characters of t using a have/need counter to track when the window is valid.
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque of indices.
Find the shortest subarray with sum >= k, handling negative numbers correctly using a monotonic deque on prefix sums.