dsa1 min read
Maximum Points You Can Obtain from Cards [Medium] — Complement Window
Maximize card points taken from both ends of an array by finding the minimum-sum subarray of size n-k in the middle.
Read →
webcoderspeed.com
1276 articles
Maximize card points taken from both ends of an array by finding the minimum-sum subarray of size n-k in the middle.
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.