Java solution with stack
I see no one use stack with java as the same idea as me, so I share my code here.\n\nIt is a bit straightforward, so need not explaination.\n\n    public class 
I see no one use stack with java as the same idea as me, so I share my code here.\n\nIt is a bit straightforward, so need not explaination.\n\n    public class Solution {\n        public void reorderList(ListNode head) {\n            if (head==null||head.next==null) return;\n            Deque<ListNode> stack = new ArrayDeque<ListNode>();\n            ListNode ptr=head;\n            while (ptr!=null) {\n                stack.push(ptr); ptr=ptr.next;\n            }\n            int cnt=(stack.size()-1)/2;\n            ptr=head;\n            while (cnt-->0) {\n                ListNode top = stack.pop();\n                ListNode tmp = ptr.next;\n                ptr.next=top;\n                top.next=tmp;\n                ptr=tmp;\n            }\n            stack.pop().next=null;\n        }\n    }
['Java']