原文:[leetcode]Partition List @ Python

原题地址:https: oj.leetcode.com problems partition list 题意: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox. You should preserve th ...

2014-06-12 09:38 0 2671 推荐指数:

查看详情

Leetcode: Partition List

思路: 1. 空间复杂度为 o(n) 解法. 创建两个链表, 分别记录大于 x 和小于 x 的节点, 最后合并 2. o(1) 的空间复杂度解法. 四个指针, 分别指向小于 x 部分链表的头, 尾 ...

Fri Dec 06 01:20:00 CST 2013 0 2432
Partition List leetcode java

题目: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should ...

Wed Jul 23 18:21:00 CST 2014 0 3863
[LeetCode] Partition List 划分链表

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve ...

Sun Mar 08 16:37:00 CST 2015 0 11175
[leetcode]Rotate List @ Python

原题地址:https://oj.leetcode.com/problems/rotate-list/ 题意: Given a list, rotate the list to the right by k places, where k is non-negative. ...

Fri Jun 13 19:19:00 CST 2014 0 3260
[leetcode]Sort List @ Python

原题地址:http://oj.leetcode.com/problems/sort-list/ 题意:链表的排序。要求:时间复杂度O(nlogn),空间复杂度O(1)。 解题思路:由于题目对时间复杂度和空间复杂度要求比较高,所以查看了各种解法,最好的解法就是归并排序,由于链表在归并操作时 ...

Wed Apr 30 00:23:00 CST 2014 0 4300
[leetcode]Reorder List @ Python

原题地址:http://oj.leetcode.com/problems/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 ...

Wed Apr 30 18:59:00 CST 2014 0 2923
[leetcode]Linked List Cycle @ Python

原题地址:http://oj.leetcode.com/problems/linked-list-cycle/ 题意:判断链表中是否存在环路。 解题思路:快慢指针技巧,slow指针和fast指针开始同时指向头结点head,fast每次走两步,slow每次走一步。如果链表不存在环,那么fast ...

Thu May 01 00:33:00 CST 2014 0 3812
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM