AddTwoNums.java - package LeetCodeLinkedList public class AddTwoNums public static class ListNode int val ListNode next ListNode(int x val = x public

AddTwoNums.java - package LeetCodeLinkedList public class...

This preview shows page 1 out of 1 page.

package LeetCodeLinkedList; public class AddTwoNums { public static class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode x = l1; ListNode y = l2; int sum, carry = 0; ListNode result = new ListNode(0); ListNode curr = result; while(x != null || y != null) {
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Fall '08
  • staff

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes