Check if Linked List is Palindrome | Striver sheet | Leetcode | Geeks For Geeks | JAVA

Опубликовано: 25 Октябрь 2024
на канале: VS Code
43
0

Problem - https://www.geeksforgeeks.org/problem...

Given a singly linked list of size N of integers. The task is to check if the given linked list is palindrome or not.

Example 1:

Input:
N = 3
value[] = {1,2,1}
Output: 1
Explanation: The given linked list is
1 2 1 , which is a palindrome and
Hence, the output is 1.
Example 2:

Input:
N = 4
value[] = {1,2,3,4}
Output: 0
Explanation: The given linked list
is 1 2 3 4 , which is not a palindrome
and Hence, the output is 0.