Skip to content

Commit 6316472

Browse files
committed
add solution of reverse-linked-list
1 parent 3604a60 commit 6316472

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

reverse-linked-list/jinhyungrhee.java

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

0 commit comments

Comments
 (0)