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