You get the head of a singly linked list. Return true if the values read the same from the back as from the front, and false otherwise.
Read backwards, the list is still 3, 8, 5, 8, 3. With an odd number of nodes, the middle one (5) has no partner and doesn't need one.
Backwards it reads 0, 9, 0, 9: the first value is 9 but the last is 0.
Constraints
1 and 10⁵ nodes.0 <= Node.val <= 9Extra challenge: take linear time but keep only a handful of pointers besides the list itself, instead of copying the values into an array or a stack.
Copying the values into an array and comparing it with its reverse works. To get by with a few pointers instead, compare the first half of the list with the second half read backwards.
true