Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: How many occurrences of "ab" are in "ababab" when occurrences may overlap?

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

Correct answer: B. 3

The pair 'ab' starts at indices 0, 2 and 4, so there are three occurrences.

More Coding Interview Problems questions

Exams that ask this topic