Skip to content

Commit ca8d5ca

Browse files
authored
Create (Leetcode) 206 Reverse Linked List.cpp
1 parent b9fe3fb commit ca8d5ca

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
ListNode* reverseList(ListNode* head) {
4+
if(!head or !head->next) return head;
5+
ListNode* t = reverseList(head->next);
6+
ListNode* sn = head->next;
7+
sn->next = head;
8+
head->next=NULL;
9+
return t;
10+
11+
12+
}
13+
};

0 commit comments

Comments
 (0)