Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: From the list [5, 3, 3, 7, 12, 9], what is the second-smallest distinct value (duplicates count once)?

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

Correct answer: A. 5

Remove duplicates, sort, and read the second value. Taking the second element of the sorted list with duplicates gives 3 instead of the second distinct value.

More Coding Interview Problems questions

Exams that ask this topic