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 6efb604 commit f3f44e4Copy full SHA for f3f44e4
1 file changed
reorder-list/se6816.java
@@ -0,0 +1,25 @@
1
+
2
+class Solution {
3
+ public void reorderList(ListNode head) {
4
+ if(head.next == null) return;
5
6
+ ListNode prev = null;
7
+ while (true) {
8
+ ListNode tail = head;
9
+ while (tail.next != null) {
10
+ prev = tail;
11
+ tail = tail.next;
12
+ }
13
14
+ if (prev == head) break;
15
16
+ // tail 이동
17
+ ListNode headNext = head.next;
18
+ prev.next = null;
19
+ head.next = tail;
20
+ tail.next = headNext;
21
22
+ head = headNext;
23
24
25
+}
0 commit comments