Deque Palindrome Check
Published at25 Jul 2026
Created by M Ichsanul Fadhil
Check if an array is a palindrome (same forwards and backwards) — simulating checking from both ends of a deque.
Example Input & Output
Example 1
Input
[]
Output
true
Explanation
Empty
Example 2
Input
[1,2,3,2,1]
Output
true
Explanation
Palindrome
Example 3
Input
[1,2,3,3,2,1]
Output
true
Explanation
Even length palindrome
Example 4
Input
[1,2,3,4]
Output
false
Explanation
Not palindrome
Example 5
Input
[1]
Output
true
Explanation
Single element
Algorithm Flow

Recommendation Algorithm Flow for Deque Palindrome Check
Solution Approach
Best Answers
java
class Solution {
public boolean solution(int[] nums) {
int l=0,r=nums.length-1;while(l<r){if(nums[l]!=nums[r])return false;l++;r--;}return true;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
