LeetCode Solutions : Reorder List
生活随笔
收集整理的這篇文章主要介紹了
LeetCode Solutions : Reorder List
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Given a singly linked list?L:?L0→L1→…→Ln-1→Ln,
reorder it to:?L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given?{1,2,3,4}, reorder itto?{1,4,2,3}.
Considering the following steps:
?* 1. split such list into two list, first and second, according to slow and fast point
?* 2. reverse the second list
?* 3. insert the second list into the first list
coding solution:
版權聲明:本文博主原創文章,博客,未經同意不得轉載。
轉載于:https://www.cnblogs.com/zfyouxi/p/4850687.html
總結
以上是生活随笔為你收集整理的LeetCode Solutions : Reorder List的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【代码笔记】iOS-对UIView进行截
- 下一篇: JS组件系列——Bootstrap Ta