583. Check if Queue is Palindrome

EasyStackQueueStack

Given a queue represented as an array (index 0 is the front), determine whether its contents read the same front-to-back as back-to-front. Return true or false. The input is JSON {queue}.

Input: JSON {queue}.

Output: Boolean — true or false.

Examples

Example 1
Input: {"queue":[1,2,1]}
Output: true
Explanation: Reads the same both ways.
Example 2
Input: {"queue":[1,2,3]}
Output: false
Explanation: Not a palindrome.
Example 3
Input: {"queue":[]}
Output: true
Explanation: Empty is a palindrome.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →