public void ReverseLinkedListProblemTest() { var solution = new ReverseLinkedListProblem(); var listNode = new ListNode(1) { next = new ListNode(2) { next = new ListNode(3) { next = new ListNode(4) { next = new ListNode(5) { next = null } } } } }; var reversed = solution.ReverseList(listNode); Assert.Null(listNode.next); Assert.Equal(5, reversed.val); Assert.Equal(4, reversed.next.val); }
public void TestReverseLinkedList() { ListNode first = new ListNode(1); ListNode second = new ListNode(2); ListNode third = new ListNode(3); first.next = second; first.next.next = third; ReverseLinkedListProblem reverse = new ReverseLinkedListProblem(); reverse.ReverseList(first); }