Leetcode, Add Two Numbers, Programming, Leetcode Medium, Java.
10; current.next = (p != null) ? p : q; current.next.val = sum % 10; current = current.next; if (p != null) p = p.next; if (q != null) q = q.next; } if (carry > 0) { current.next = new ListNode(carry); } return dummy.next; } } Time and Space Complexity Time Complexity: O(n), the optimized iterative