public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        int carrier = 0;
        int val = 0;
        ListNode head = new ListNode(0);
        ListNode cur = head;
        while(l1 != null || l2 != null)
        {
            if(l1 != null)
                val += l1.val;
            if(l2 != null)
                val += l2.val;
            cur.next = new ListNode( (val + carrier) % 10 );
            carrier = (val + carrier) / 10;
            cur = cur.next;
            l1 = l1==null?l1:l1.next;
            l2 = l2==null?l2:l2.next;
            val = 0;
        }
        if(carrier == 1)
            cur.next = new ListNode(1);
        return head.next;
    }