Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Smallest Period > Editorial

Smallest Period — Solution & Editorial

Back to the Problem

Compute the KMP prefix function; the candidate period is |S| − π[|S|−1], and it is the true period iff it divides |S|.

Complexity: O(|S|)

Watch out: |S| − π[last] is only the period when it divides the length — abcab has period 5, not 3.