Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many pairs of non-overlapping equal substrings of length 2 exist in "abababab" (positions i < j with j >= i + 2)?

  1. A. 9
  2. B. 10
  3. C. 8
  4. D. 2

Correct answer: A. 9

Count position pairs whose length-2 substrings match and whose intervals do not overlap (j >= i + 2). Overlapping matches like positions 0 and 1 are excluded by that condition.

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

Exams that ask this topic