LeetCode :Reorder List
public void reorderList(ListNode head) {
if(head==null||head.next==null){
return ;
}
int len=0;
ListNode p=head;
ListNode end=head;
ListNode q;
ListNode next;
while(p!=null){
len++;
p=p.next;
}
for(int i=0;i<len>>1;i++){
end=end.next;
}
q=end.next;
end.next=null;
Stack<ListNode> stack = new Stack<ListNode>();
while(q!=null){
stack.push(q);
q=q.next;
}
p=head;
while(p!=null&&!stack.empty()){
q=stack.pop();
next=p.next;
p.next=q;
q.next=next;
p=next;
}
}