Add one to the number represented by linkedlist

here is the question->https://practice.geeksforgeeks.org/problems/add-1-to-a-number-represented-as-linked-list/1
my code->
https://ide.codingblocks.com/s/374586
i am not able handle corner case when
999 output should be 1000 help me i am getting 100 only

hello @sheikhhaji18

even after correcting that ur code will fail.

image

becuase in worst case u will have 1000 digits which u cannot store in any primitive datatype.

so instead of convert list to number and then number of list.

reverse the given list , add 1 to the first node and propage the generated carray forward.
if in then end carry !=0 then add new node in and initilaise it with carry.

rever the generated list and return head

is this a type of big integer problem

yeah u can say that.
but here we are storing each digit in list instead of using any library

another doubt why is not code adding 0 to the last of the linked list

just to know what i am doing wrong

after reversing 1000 , it will be 0001 which be treated as 1 becuase we cannot have leading zeros in int datatype .
thats why u r not getting 0s in the end