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 b664c6c commit 2ef7791Copy full SHA for 2ef7791
โreverse-linked-list/yeonguchoe.c
@@ -0,0 +1,25 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * struct ListNode {
4
+ * int val;
5
+ * struct ListNode *next;
6
+ * };
7
+ */
8
+struct ListNode* reverseList(struct ListNode* head) {
9
+
10
+ struct ListNode* ptr1 = NULL;
11
+ struct ListNode* ptr2 = head;
12
+ struct ListNode* ptr3 = NULL;
13
14
+ while (ptr2 != NULL) {
15
+ ptr3 = ptr2->next;
16
+ ptr2->next = ptr1;
17
18
+ // ์์ผ๋ก ์ ์ง
19
+ ptr1 = ptr2;
20
+ ptr2 = ptr3;
21
+ }
22
+ return ptr1;
23
+}
24
+// ์๊ฐ ๋ณต์ก๋: O(๋ ธ๋ ๊ฐ์)
25
+// ๊ณต๊ฐ ๋ณต์ก๋: O(1)
0 commit comments