Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the length of the longest substring of banana that appears at least twice in the string (occurrences may overlap)?

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

Correct answer: C. 3

The substring ana appears at positions 1 and 3 with overlap, so its length is 3. Checking only non-overlapping occurrences would miss it.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic