diff --git a/LinkedListPalindrome/README.md b/LinkedListPalindrome/README.md index 7928ba3..e600da0 100644 --- a/LinkedListPalindrome/README.md +++ b/LinkedListPalindrome/README.md @@ -3,6 +3,7 @@ Suppose we have a singly-linked list (so you can only traverse the list in one direction) class where each list node contains a single character or integer. Implement a function to check if the elements in the linked list form a palindrome. For example, given the linked list below: + ```js class ListNode { constructor(value) { @@ -16,9 +17,13 @@ const b = new ListNode(2); const c = new ListNode(3); const d = new ListNode(2); const e = new ListNode(1); +a.next = b; +b.next = c; +c.next = d; +d.next = e; -isLinkedListPalindrome(a); // should return true -isLinkedListPalindrome(b); // should return false since now the 'a' node is not included in the linked list +isLinkedListPalindrome(a); // should return true +isLinkedListPalindrome(b); // should return false since now the 'a' node is not included in the linked list ``` -Analyze the time and space complexity of your solution. \ No newline at end of file +Analyze the time and space complexity of your solution.