private static void AssertListsEqual(MergeTwoSortedLists_21.ListNode expected, MergeTwoSortedLists_21.ListNode actual) { var l = expected; var r = actual; while (l != null && r != null) { Assert.Equal(l.Val, r.Val); l = l.Next; r = r.Next; } Assert.Null(l); Assert.Null(r); }
private static MergeTwoSortedLists_21.ListNode InlineDataStringToList(string str) { if (string.IsNullOrEmpty(str)) { return(null); } var head = new MergeTwoSortedLists_21.ListNode(-1); var n = head; foreach (var i in str.Split(",").Select(int.Parse)) { n.Next = new MergeTwoSortedLists_21.ListNode(i); n = n.Next; } return(n.Next); }