Data Structures & AlgorithmsVery hardTCS NQT · Accenture

What is the lexicographically smallest rotation of the string bca?

  1. A. bca
  2. B. cab
  3. C. abc
  4. D. acb

Correct answer: C. abc

The rotations of bca are bca, cab and abc; comparing them character by character, abc is smallest because it is the only one starting with a. acb is not a rotation at all (it is a permutation), so it cannot be chosen.

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

Exams that ask this topic