Leetcode, Add Two Numbers, Programming, Leetcode Medium, Java.
Initialize a pointer to build the result list int carry = 0; // Initialize the carry to 0 while (l1 != null || l2 != null) { // Traverse both lists int x = (l1 != null) ? l1.val : 0; // Get the value of the current node in l1, or 0 if l1 is null int y = (l2 != null) ? l2.val : 0; // Get the value