Skip to content

Latest commit

 

History

History

addlist

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Increment a Number Presented as a Linked-List

Problem

Increment a number represented as a linked list. Each node contains a single digit and the most significant digit is stored in the head of the list.

Do not reverse the linked-list before performing the increment.

For example:

[ 1 ] --> [ 2 ] --> [ 3 ]   =>   [ 1 ] --> [ 2 ] --> [ 4 ]
[ 1 ] --> [ 9 ] --> [ 9 ]   =>   [ 2 ] --> [ 0 ] --> [ 0 ]

Source:

https://ashayraut.files.wordpress.com/2014/05/interview-preparation-best-100-ashay-raut.pdf