Data Structures & AlgorithmsHardICPC regional · Product Company SDE

Problem: The string "mississippi" contains repeated substrings. What is the length of the longest substring that appears at least twice (occurrences may overlap)?

  1. A. 5
  2. B. 3
  3. C. 6
  4. D. 4

Correct answer: D. 4

Test every length from the largest down: 'issi' appears at positions 1 and 4, so length 4 repeats, and no longer substring does. Checking only single letters underestimates the answer.

More Coding Interview Problems questions

Exams that ask this topic