Given a stack represented as an array, determine whether its contents read the same from bottom to top as from top to bottom. Return true or false. The input is JSON {stack}.
Input: JSON {stack}.
Output: Boolean — true or false.
Input: {"stack":[1,2,3,2,1]}
Output: true
Explanation: Reads the same both ways.Input: {"stack":[1,2,3]}
Output: false
Explanation: Not a palindrome.Input: {"stack":[7]}
Output: true
Explanation: A single element is a palindrome.0<=n<=10^5