Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

A string "cdeab" is rotated left by some number of steps k (0 <= k < 5) to become "abcde". What is the smallest such k?

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

Correct answer: A. 3

A left rotation by k moves the first k characters to the end. Rotating "cdeab" by 3 gives "abcde", and no smaller shift works.

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

Exams that ask this topic