Data Structures & AlgorithmsHardTCS NQT · Accenture

What is the rank (1-based, in lexicographic order) of the string cab among all permutations of the letters a, b, c?

  1. A. 6
  2. B. 5
  3. C. 4
  4. D. 7

Correct answer: B. 5

The six permutations sorted are abc, acb, bac, bca, cab, cba; the factorial number system gives the same position directly.

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

Exams that ask this topic