Data Structures & AlgorithmsHardTCS NQT · Infosys

How many adjacent position pairs in the string abbaabab are equal to ab or ba (overlapping adjacent pairs counted)?

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

Correct answer: B. 5

Check each of the seven adjacent pairs: ab, bb, ba, aa, ab, ba, ab. Five of them are ab or ba.

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

Exams that ask this topic