Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: A stream of 12 numbers 5, 1, 4, 4, 2, 5, 3, 1, 2, 3, 3, 4 arrives. How many distinct values appear at least twice in the stream?

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

Correct answer: D. 5

Count the frequency of each value and tally those with frequency of at least two. Counting total repeated positions (occurrences beyond the first) is a different quantity.

More Coding Interview Problems questions

Exams that ask this topic