MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / reverse

Function reverse

GeeksForGeeks/Palindrome_Linked_List/Solution.cpp:89–103  ·  view source on GitHub ↗

Reversing the second half of the linked list

Source from the content-addressed store, hash-verified

87
88//Reversing the second half of the linked list
89void reverse(struct Node** head_ref)
90{
91 struct Node* prev = NULL;
92 struct Node* current = *head_ref;
93 struct Node* next;
94
95 //Run a loop for reversing the linked list
96 while (current != NULL) {
97 next = current->next;
98 current->next = prev;
99 prev = current;
100 current = next;
101 }
102 *head_ref = prev;
103}
104
105//Comparing the first and the second half of the linked list
106bool compareLists(struct Node* head1, struct Node* head2)

Callers 1

isPalindromeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected