Palindrome LinkedList

Ritik Raj
2 min readOct 1, 2022

--

Palindrome LinkedLists are those LinkedList that are the same when reversed

Question

You have been given a head to a singly linked list of integers. Write a function check to whether the list given is a ‘Palindrome’ or not.

Some Examples: -

Image of Example

Input Format:

The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow.

First and the only line of each test case or query contains the the elements of the singly linked list separated by a single space.

Output Format:

For each test case, the only line of output that print 'true' if the list is Palindrome or 'false' otherwise.

Constraints :

1 <= t <= 10^2
0 <= M <= 10^5
Time Limit: 1sec

Where 'M' is the size of the singly linked list.

Sample Input:

1
9 2 3 3 2 9 -1

Sample Output:

true

Answer:-

Main File:

Solution.cpp

Our Question is completed🙌🙌

Ping me on LinkedIn :

https://www.linkedin.com/in/ritik-raj-profile/

--

--

Ritik Raj
Ritik Raj

Written by Ritik Raj

Co-Lead in Google Developer Student Club MMDU || Flutter Developer

No responses yet