Skip to content

Commit df2d253

Browse files
Create Reverse LinkedList- 206
1 parent 4fca521 commit df2d253

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Reverse LinkedList- 206

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public ListNode reverseList(ListNode head) {
3+
ListNode curr = head;
4+
ListNode prev = null;
5+
ListNode next = null;
6+
while(curr!=null){
7+
next = curr.next;
8+
curr.next = prev;
9+
prev = curr;
10+
curr = next;
11+
}
12+
return prev;
13+
}
14+
}

0 commit comments

Comments
 (0)