Problem Challenge 1

Palindrome LinkedList (medium) #

Given the head of a Singly LinkedList, write a method to check if the LinkedList is a palindrome or not.

Your algorithm should use constant space and the input LinkedList should be in the original form once the algorithm is finished. The algorithm should have O(N)O(N) time complexity where ā€˜N’ is the number of nodes in the LinkedList.

Example 1:

Input: 2 -> 4 -> 6 -> 4 -> 2 -> null
Output: true

Example 2:

Input: 2 -> 4 -> 6 -> 4 -> 2 -> 2 -> null
Output: false

Try it yourself #

Try solving this question here:

Output

0.468s

Is palindrome: False Is palindrome: False

Mark as Completed
←    Back
Middle of the LinkedList (easy)
Next    →
Solution Review: Problem Challenge 1