1、双指针算法
import java.util.*;
public class Solution {
public void reorderList(ListNode head) {
if (head == null || head.next == null) return;
List<ListNode> list = new ArrayList<>();
ListNode cur = head;
while (cur != null) {
list.add(cur);
cur = cur.next;
}
int l = 0, r = list.size() - 1;
while (l < r) {
list.get(l).next = list.get(r);
l++;
list.get(r).next = list.get(l);
r--;
}
list.get(l).next = null;
}
} 
京公网安备 11010502036488号