dsa1 min read
Get Equal Substrings Within Budget [Medium] — Variable Window Cost
Find the maximum length substring you can transform from s to t within a given cost budget using a sliding window on character change costs.
Read →
webcoderspeed.com
1276 articles
Find the maximum length substring you can transform from s to t within a given cost budget using a sliding window on character change costs.
Count substrings containing at least one a, b, and c using the last-seen indices shortcut for O(n) time.
Count subarrays with sum divisible by k using prefix sum modulo k and a frequency map of remainders.
Find k closest integers to x in a sorted array using binary search to locate the optimal left boundary of the window.
Count subarrays where min=minK and max=maxK using a single pass tracking the last invalid position and last positions of minK and maxK.