Palindrome Linked List Solution in Java

Day 49 of Daily DSA 🚀 Solved LeetCode 234: Palindrome Linked List ✅ Problem: Given the head of a singly linked list, return true if it is a palindrome, otherwise false. Approach: Used a stack-based method to compare linked list values from both directions. Steps: Traverse the linked list and push all node values into a stack Start again from head Pop values one by one from stack Compare current node value with popped value If mismatch found → return false If all match → return true ⏱ Complexity: • Time: O(n) • Space: O(n) 📊 LeetCode Stats: • Runtime: 15 ms • Memory: 101.66 MB Sometimes using extra space can make the logic cleaner and easier to implement. #DSA #LeetCode #Java #LinkedList #Stack #CodingJourney #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories