From 2802c436e22b378d863f7aeb98cb1d91bfacb842 Mon Sep 17 00:00:00 2001 From: amanydv72 <89766177+amanydv72@users.noreply.github.com> Date: Tue, 11 Oct 2022 06:51:08 +0530 Subject: [PATCH] 206. Reverse Linked List solution of issue #88 in c --- Leetcode-Easy/Reverse_Linked_List.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Leetcode-Easy/Reverse_Linked_List.c diff --git a/Leetcode-Easy/Reverse_Linked_List.c b/Leetcode-Easy/Reverse_Linked_List.c new file mode 100644 index 0000000..426f464 --- /dev/null +++ b/Leetcode-Easy/Reverse_Linked_List.c @@ -0,0 +1,23 @@ +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * struct ListNode *next; + * }; + */ + + +struct ListNode* reverseList(struct ListNode* head) +{ + struct ListNode *q=NULL,*r=NULL; + while(head) + { + r=q; + q=head; + head=head->next; + q->next=r; + } + head=q; + return head; + +}