Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: Count the occurrences of the pattern "aba" in "abababa", where occurrences may overlap.

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

Correct answer: A. 3

Overlapping matches at every starting index give the count. Scanning non-overlapping blocks misses some occurrences.

More Coding Interview Problems questions

Exams that ask this topic