Data Structures & AlgorithmsHardTCS NQT · Infosys

Two numbers are stored as linked lists of digits, least significant digit first: 9 -> 9 -> 9 and 1. Their sum is added digit by digit with carry. How many nodes does the resulting list have?

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

Correct answer: A. 4

999 + 1 = 1000, and the list keeps the final carry as an extra node, giving 4 nodes: 0, 0, 0, 1.

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

Exams that ask this topic