dsa1 min read
Rotate String [Easy] — String Contains Trick
Check if string B is a rotation of A by checking if B appears in A+A using a substring search.
Read →
webcoderspeed.com
1276 articles
Check if string B is a rotation of A by checking if B appears in A+A using a substring search.
Find the minimum times A must repeat so that B is a substring, using a tight bound on the number of repeats needed.
Calculate trapped rain water using inward two pointers that track left-max and right-max, replacing the classic O(n) space approach.
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque.
Find the smallest missing positive integer in O(n) time O(1) space using in-place cyclic sort to place each number at its correct index.