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

Sign in to watch this lesson
Advanced - Strings · 4:59
The prefix function does far more than drive KMP. We count how often every prefix of a string occurs by pushing counts down the border chain, read the shortest repeating unit straight off the last value, and turn the table into a full automaton whose missing transitions are copied from earlier rows in O(26 n). Then the automaton counts pattern matches inside Gray strings with 2^60 characters by storing what each half does to every state.