IsListPalindrome
Last updated
Last updated
Given a singly linked list of integers, determine whether or not it's a .
Example
For l = [0, 1, 0]
, the output should be
solution(l) = true
;
For l = [1, 2, 2, 3]
, the output should be
solution(l) = false
.
Push the copy of head to stack (1,2,2,1)
Start from start of head, pop stack (the last element added to stack)
If poped element = head element, continue iteration; else, not palindrome