File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,20 @@ public ListNode sortList(ListNode head) {
4
4
return head ;
5
5
}
6
6
7
- ListNode prev = null , slow = head , fast = head ;
7
+ ListNode tortoise = head , hare = head , prev = tortoise ;
8
8
9
- while (fast != null && fast .next != null ) {
10
- prev = slow ;
11
- slow = slow .next ;
12
- fast = fast .next .next ;
9
+ while (hare != null && hare .next != null ) {
10
+ prev = tortoise ;
11
+ tortoise = tortoise .next ;
12
+ hare = hare .next .next ;
13
13
}
14
14
15
15
prev .next = null ;
16
16
17
- ListNode l1 = sortList (head );
18
- ListNode l2 = sortList (slow );
17
+ ListNode h1 = sortList (head );
18
+ ListNode h2 = sortList (tortoise );
19
19
20
- return merge (l1 , l2 );
20
+ return merge (h1 , h2 );
21
21
}
22
22
23
23
private ListNode merge (ListNode l1 , ListNode l2 ) {
You can’t perform that action at this time.
0 commit comments