AddTwoNumbers { public ListNode addTwoNumbersII(ListNode<Integer> l1, ListNode<Integer> l2) { int len1 = length(l1), len2 = length(l2); int max = Math.max(len1, len2); int min = Math.min(len1, len2); ListNode<Integer> lln = (len1 > len2) ? l1 : l2; ListNode<Integer> sln = (l1 == lln) ? l2 : l1; ListNode<Integer> sum = add(lln, sln, max, min); normalize(sum); if (sum.val == 0) { return sum.next; } else { return sum; } }  ListNode addTwoNumbersI(ListNode<Integer> l1, ListNode<Integer> l2); ListNode addTwoNumbersII(ListNode<Integer> l1, ListNode<Integer> l2);  }
@Test(dataProvider = "addersII") public void testAddNumbersII(ListNode<Integer> adder1, ListNode<Integer> adder2, List<Integer> expectedSum) { ListNode<Integer> actual = new AddTwoNumbers().addTwoNumbersII(adder1, adder2); TestUtilities.assertLinkedListValues(actual, expectedSum); }