137. Is the List a Palindrome?
Challenge1000 ms256 MBSolved by 0%
Build the list and print Yes if the values read the same forwards and
backwards, or No otherwise.
An empty list counts as a palindrome.
Constraints - `0 ≤ n ≤ 100000` - `-1000000 ≤ value ≤ 1000000`
Input
The first line contains an integer n, the number of nodes.
The second line contains n space-separated integers, the node values from head to tail.
The starter code builds the list for you; work on the nodes, not the array.
Output
Print exactly one word: Yes or No. An empty list counts as a palindrome.
Input5
1 2 3 2 1
OutputYes
Noteis an odd-length palindrome
Input4
1 2 2 1
OutputYes
Noteis an even-length palindrome
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.