We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b25a99 commit 9cb478fCopy full SHA for 9cb478f
reverse-linked-list/minji-go.java
@@ -0,0 +1,21 @@
1
+/**
2
+ * <a href="https://leetcode.com/problems/reverse-linked-list/">week07-1.reverse-linked-list</a>
3
+ * <li>Description: return the reversed list </li>
4
+ * <li>Topics: Linked List, Recursion </li>
5
+ * <li>Time Complexity: O(N), Runtime 0ms </li>
6
+ * <li>Space Complexity: O(1), Memory 43.04MB </li>
7
+ */
8
+class Solution {
9
+ public ListNode reverseList(ListNode head) {
10
+ ListNode prev = null;
11
+ ListNode curr = head;
12
+ while (curr != null) {
13
+ ListNode temp = curr.next;
14
+ curr.next = prev;
15
+ prev = curr;
16
+ curr = temp;
17
+ }
18
+
19
+ return prev;
20
21
+}
0 commit comments