manasec / hacktoberfest2019-leetcode

This repository is a collection of all the LeetCode problem solutions using different programming languages. Happy HacktoberFest-2019!!! #hacktoberfest #firstpullrequest
MIT License
5 stars 40 forks source link

Problem 234 - SLL palindrome #26

Closed gaurikapoplai21 closed 4 years ago

gaurikapoplai21 commented 4 years ago

This is a function in C language which checks if a singly linked ist is a palindrome or not. It first puts the contents of the singly linked list in a stack and then it traverses through the linked list again whilst comparing each element of the SLL to the corresponding popped element of the stack. If the number of successful comparisions = length of the linked list, then its a palindrome otherwise not. This function is approximately 73% faster than other submissions of the same on leet code