Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many length-3 substrings of "abcabc" are rotations of "abc" (namely abc, bca or cab)?

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

Correct answer: B. 4

Every length-3 window of abcabc is one of the three rotations, and there are four windows, so the count is 4.

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

Exams that ask this topic