We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bc8e248 commit a7471dcCopy full SHA for a7471dc
LinkedList/LinkedList.java
@@ -360,4 +360,29 @@ public void seperateEvenodd () {
360
oddEnding.next=null;
361
head=evenStarting;
362
}
363
+ public void addOne(){
364
+ reverse();
365
+ addOneInner();
366
367
+ }
368
+ private void addOneInner(){
369
+ Node temp=head;
370
+ Node prev=null;
371
+ int carry=1;
372
+ while(temp!=null){
373
+ int sum=0;
374
+ sum=carry+temp.data;
375
+ carry=sum/10;
376
+ sum=sum%10;
377
+ temp.data=sum;
378
+ prev=temp;
379
+ temp=temp.next;
380
381
+ if(carry>0){
382
+ Node node=new Node();
383
+ node.data=carry;
384
+ node.next=null;
385
+ prev.next=node;
386
387
388
0 commit comments