Data Structures & AlgorithmsVery hardTCS NQT · Accenture
What is the lexicographically smallest rotation of the string bca?
- A. bca
- B. cab
- C. abc
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the sum of all integers x in [1, 50] that are divisible by 4 or by 6?
- How many positive divisors of 360 are odd?
- What is the largest n such that 1 + 2 + ... + n does not exceed 1000?
- How many primes p with 2 <= p <= 30 satisfy p ≡ 1 (mod 4)?
- How many integers x in [1, 100] satisfy x ≡ 3 (mod 4) and x ≡ 7 (mod 10)?
- What is 2^100 mod 9?