Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

Which string is the lexicographically smallest rotation of "bcabca"?

  1. A. abcabc
  2. B. bcabca
  3. C. cabcab
  4. D. abcbca

Correct answer: A. abcabc

Compare all rotations; the smallest starts at the lexicographically minimal suffix. Using Booth's or the doubled-string trick yields the same answer, while printing the original string is a trap.

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

Exams that ask this topic