dsa1 min read
Number of Subarrays with Bounded Maximum [Medium] — Counting Pattern
Count subarrays where max element is in [L,R] using a clever counting formula with two linear scans.
Read →
webcoderspeed.com
1276 articles
Count subarrays where max element is in [L,R] using a clever counting formula with two linear scans.
Count subarrays with exactly K distinct integers using the formula: atMost(K) - atMost(K-1).
Find the minimum rotations to make all tops or bottoms equal by checking if a target value (from first domino) can unify the entire row.
Reconstruct the stamp sequence in reverse by greedily finding where the stamp can overwrite current characters in the target string.
Find the longest substring that appears at least twice using binary search on length and Rabin-Karp rolling hash for O(n log n) average time.