Leetcode, Add Two Numbers, Programming, Leetcode Medium, Java.
Initialize a pointer to build the result list ListNode p = l1; // Pointer to traverse l1 ListNode q = l2; // Pointer to traverse l2 int carry = 0; // Initialize the carry to 0 while (p != null || q != null) { // Traverse both lists int x = (p != null) ? p.val : 0; // Get the value of the current