Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: The array [5, 2, 8, 2, 9, 1, 5, 5] contains repeated values. How many distinct values appear exactly twice?

  1. A. 2
  2. B. 0
  3. C. 1
  4. D. 3

Correct answer: C. 1

Count occurrences of each value and tally those with exactly two. Value 5 appears three times, so it does not qualify; only 2 appears exactly twice.

More Coding Interview Problems questions

Exams that ask this topic