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?
- A. 6
- B. 5
- C. 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.
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
- How many trailing zeros does 2024! have in base 10?
- How many integers n with 2 <= n <= 200 are square-free (not divisible by the square of any integer greater than 1)?
- What is the sum of Euler's totient phi(i) for i = 1 to 10 (phi(i) counts the integers k in [1, i] with gcd(k, i) = 1)?
- How many integers x in [0, 20] satisfy x^3 ≡ x (mod 7)?
- The 3-row by 4-column matrix is filled row by row with 1 to 12. What is the 7th element when the matrix is read in clockwise spiral order…
- A sliding window of size 3 moves over the array [5, 1, 4, 2, 8, 7, 6]. For each window take its maximum and then take the minimum of those…