Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: How many distinct strings are obtained from "abab" by cyclic rotations (including the rotation by 0)?

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

Correct answer: A. 2

Distinct rotations are counted as strings, so periodic strings produce repeats. Counting rotation indices gives 4, which overstates the number of distinct strings.

More Coding Interview Problems questions

Exams that ask this topic