Data Structures & AlgorithmsHardTCS NQT · Accenture

A list holds 1, 1, 2, 2, 2, 3, 1, 1. Consecutive duplicates are merged into one node each. What is the sum of the values left in the list?

  1. A. 7
  2. B. 8
  3. C. 9
  4. D. 11

Correct answer: A. 7

The merged list is 1, 2, 3, 1 with sum 7. Removing all copies of a value (not just consecutive ones) would give a different list.

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

Exams that ask this topic