leetcode日志:解题参考引用

283. Move Zeroes

给定一个数组nums,编写函数将数组内所有0元素移至数组末尾,并保持非0元素相对顺序不变。例如,给定nums = [0, 1, 0, 3, 12],调用函数完毕后, nums应该是 [1, 3, 12, 0, 0]。

要点:双指针

题目:https://leetcode.com/problems/move-zeroes/

解答:http://www.2cto.com/kf/201512/455439.html

-------------------------------------------------------------------------------------------------------------------

328. Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

Example:
Given 1->2->3->4->5->NULL,
return 1->3->5->2->4->NULL.

Note:
The relative order inside both the even and odd groups should remain as it was in the input. 
The first node is considered odd, the second node even and so on ...

要点:第一个节点被默认为奇数,第二个为偶数,奇偶交错排列,所以分别,取得第一个和第二个节点的指针,当作奇数和偶数的链表头,然后将每个奇数放入奇数链表,偶数放入偶数链表,最后连起来。

解答:http://blog.csdn.net/guicaisa/article/details/50557475

-------------------------------------------------------------------------------------------------------------------

83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.

For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.

要点:注意是sorted,因此可以使用双指针,指针index和指针current,如果current与index相同那么进行跳过操作,之后current++,index++;如果不同,那么久不执行跳过操作,index不动,但current需要增加。

解题之一:http://blog.csdn.net/feliciafay/article/details/18072359

---------------------------------------------------------------------------------------------------------------------------------------------

107. Binary Tree Level Order Traversal II

http://www.cnblogs.com/Azhu/p/4132676.html

http://www.2cto.com/kf/201601/487081.html

http://www.acmerblog.com/leetcode-solution-binary-tree-zigzag-level-order-traversal-6239.html

http://blog.csdn.net/sunao2002002/article/details/46280539



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值