public void _2_1_RemoveDupsIterative_Test2() { Node expected = TestLinkedLists._123(); Node input = TestLinkedLists._11122233(); Node actual = _practice.Problem_2_1_Iterative(input); Assert.AreEqual(true, LinkedListUtilityMethods.AreLinkedListsEqual(actual, expected)); }
public void _2_1_RemoveDupsRecursive_Test1() { Node expected = TestLinkedLists._12345(); Node input = TestLinkedLists._1234555(); Node actual = _practice.Problem_2_1_Recursive(input); Assert.AreEqual(true, LinkedListUtilityMethods.AreLinkedListsEqual(actual, expected)); }
private Node ReverseLinkedList(Node first) { Node head = LinkedListUtilityMethods.CloneList(first); Node prev = null; Node current = head; Node next = null; while (current != null) { next = current.Next; current.Next = prev; prev = current; current = next; } return(prev); }
public bool IsPalindrome(Node head) { Node reversedList = ReverseLinkedList(head); return(LinkedListUtilityMethods.AreLinkedListsEqual(head, reversedList)); }