Skip to content

Commit b83dda4

Browse files
committed
added description for plaindrome
1 parent 257f428 commit b83dda4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Data Structures/Linked Lists/check_if_linkedlist_is_a_palindrome.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
#include <iostream>
44
using namespace std;
55

6+
7+
/*
8+
Approch used:
9+
-First traverse the LL to the middle node
10+
using floyd's algorithm.
11+
-Than reverse the second half of the Linked list.
12+
-Reset the fast pointer to head and compare each node.
13+
14+
-If Any does not match, the LL is not a palindrome.
15+
16+
17+
*/
618
struct Node
719
{
820
int data;

0 commit comments

Comments
 (0)