Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: The string "cabbage" is sorted by letter using a stable sort on the letters only. What is the 4th character of the sorted string?

  1. A. a
  2. B. c
  3. C. b
  4. D. e

Correct answer: C. b

Sorting the letters gives a, a, b, b, c, e, g; the fourth character is b. Sorting by ASCII codes gives the same result here since all letters are lowercase.

More Coding Interview Problems questions

Exams that ask this topic