今際の国の呵呵君
Friday, December 28, 2018
[LeetCode]Odd Even Linked List
这道题的基本思路就是,把奇数位置的节点连起来,偶数位置的节点连起来,最后merge起来即可。分别各用两个指针来track奇数链表和偶数链表的头尾节点,O(N)时间,常数空间。代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment