Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 35s1 days 16 hours 1 minutes 35 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 35s1 days 16 hours 1 minutes 35 seconds.

Sign in to watch this lesson
Algorithms - Strings · 4:07
Counting characters with a frequency array cnt[26]: two words are anagrams exactly when their count arrays are equal, a sliding window finds every anagram of a pattern in O(n + m) by updating two counters per step, and letters can be rearranged into a palindrome when at most one count is odd. Then palindromes from the outside in (two pointers, and a near miss that must try both deletions) and from the inside out (expanding around odd and even centres on abababc and cbaabd, after cp-algorithms.com), and the quadratic cost of expanding every centre of aaa...a, measured, which Manacher's algorithm later removes.