0

I am getting number formate exception in this code problem is given two linkedList sum of linked list one and two can be obtai

class Solution{ //Function to add two numbers represented by linked list. static Node addTwoLists(Node first, Node second){ String f = ""; Node t1 = first; while(t1 != null){ f = f+t1.data; t1 = t1.next; } String s = ""; Node t2 = second; while(t2 != null){ s = s+t2.data; t2 = t2.next; } int num = Integer.parseInt(f)+ Integer.parseInt(s); String str = String.valueOf(num); Node dum = new Node(100); str.trim(); Node ans = add(dum,str); return removeLastNode(ans); } static Node add(Node head,String str){ // Node temp = head; for(int i = str.length()-1;i>=0;i--){ char ch = str.ch

7th Oct 2023, 1:47 PM
DevjiCoder
DevjiCoder - avatar
1 ответ
+ 4
Please remove the tags „das“ „help“ and let us know there the programming language.
7th Oct 2023, 2:59 PM
JaScript
JaScript - avatar