File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ Subproject commit 047a415438a8373121413e6a52fd11bdca53efbf
Original file line number Diff line number Diff line change
1
+ Subproject commit 58e2901afafa568cb0f15d5e002c23444e22cf31
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Definition for singly-linked list.
3
+ * public class ListNode {
4
+ * int val;
5
+ * ListNode next;
6
+ * ListNode() {}
7
+ * ListNode(int val) { this.val = val; }
8
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9
+ * }
10
+ */
11
+
12
+ // 시간 복잡도: O(N)
13
+ // 공간복잡도: O(N)
14
+ class Solution {
15
+ public ListNode reverseList (ListNode head ) {
16
+ if (head ==null ) return head ;
17
+
18
+ ListNode pointer = new ListNode (head .val );
19
+
20
+ ListNode tempPointer ;
21
+ while (head .next !=null ){
22
+ tempPointer = new ListNode (head .next .val , pointer );
23
+ pointer = tempPointer ;
24
+ head = head .next ;
25
+ }
26
+ }
27
+ return pointer ;
28
+ }
29
+
Original file line number Diff line number Diff line change
1
+ Subproject commit 32ed2baa8e51b39625f99ea72a780c6edca6e9ee
You can’t perform that action at this time.
0 commit comments