public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode res = new ListNode(-1);
        ListNode ptr = res;
        int overflow = 0;
        while (l1 != null && l2 != null) {
            int sum = (overflow + l1.val + l2.val) % 10;
            overflow = (overflow + l1.val + l2.val) / 10;
            ListNode next = new ListNode(sum);
            res.next = next;
            l1 = l1.next;
            l2 = l2.next;
            res = res.next;
        }
        while (l1 != null) {
            int sum = (overflow + l1.val) % 10;
            overflow = (overflow + l1.val) / 10;
            ListNode next = new ListNode(sum);
            res.next = next;
            l1 = l1.next;
            res = res.next;
        }
        while (l2 != null) {
            int sum = (overflow + l2.val) % 10;
            overflow = (overflow + l2.val) / 10;
            ListNode next = new ListNode(sum);
            res.next = next;
            l2 = l2.next;
            res = res.next;
        }
        if (overflow > 0) {
            ListNode next = new ListNode(overflow);
            res.next = next;
        }
        return ptr.next;
    }