Data Structures & AlgorithmsVery hardTCS NQT · Accenture

A sorted linked list is [1, 1, 2, 3, 3, 3, 4]. All duplicate nodes are removed so that each value appears once. What is the sum of the values remaining?

  1. A. 11
  2. B. 12
  3. C. 10
  4. D. 13

Correct answer: C. 10

The distinct values are 1, 2, 3 and 4, with sum 10. Summing the original list would give 17.

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

Exams that ask this topic