We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a6b571f commit e26c07aCopy full SHA for e26c07a
DataStructures/LinkedList/linkedlist
40 Bytes
DataStructures/LinkedList/linkedlist.cpp
@@ -211,9 +211,24 @@ node * mergesortLL(node* head){
211
212
}
213
214
+node* reverseLL(node* head){
215
+ if(head == NULL || head->next == NULL)
216
+ return head;
217
+
218
+ node* small = reverseLL(head->next);
219
220
+ node* temp = small;
221
+ while(temp->next != NULL){
222
+ temp = temp->next;
223
+ }
224
+ temp->next = head;
225
+ head->next = NULL;
226
227
+ return small;
228
+}
229
int main(){
230
node *head = takeinput2();
231
- node* h = mergesortLL(head);
232
+ node* h =reverseLL(head);
233
print(h);
234
0 commit comments