Data Structures & AlgorithmsModerateTCS NQT · Accenture

An array has values [1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 5]. Every value that occurs more than twice is removed entirely. How many elements remain?

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

Correct answer: C. 4

Values 1 and 4 occur more than twice and are removed. The remaining elements are 2, 2, 3 and 5.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic