码迷,mamicode.com
首页 >  
搜索关键字:python实现    ( 3105个结果
Python实现快速排序
这里采用的是算法导论的划分方式: import random def partition(array, left, right): pivot = array[left] i = left #j left +1 -> right for j in range(left + 1, right + 1)...
分类:编程语言   时间:2014-12-27 22:55:47    阅读次数:317
leetcode 【 Reverse Words in a String 】python 实现
题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".代码:oj在线测试通过Runtime:172 ms 1...
分类:编程语言   时间:2014-12-27 01:26:47    阅读次数:232
leetcode 【Rotate List 】python 实现
题目:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.代码...
分类:编程语言   时间:2014-12-27 00:14:19    阅读次数:332
leetcode 【 Intersection of Two Linked Lists 】python 实现
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: ...
分类:编程语言   时间:2014-12-27 00:09:39    阅读次数:182
leetcode 【 Linked List Cycle 】 python 实现
题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?代码:oj在线测试通过Runtime:416 ms 1 # Definitio...
分类:编程语言   时间:2014-12-26 16:37:09    阅读次数:220
leetcode 【 Remove Duplicates from Sorted List 】 python 实现
题目:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, r...
分类:编程语言   时间:2014-12-26 16:23:24    阅读次数:163
leetcode 【 Remove Duplicates from Sorted List II 】 python 实现
题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2-...
分类:编程语言   时间:2014-12-26 16:19:58    阅读次数:157
leetcode 【 Remove Nth Node From End of List 】 python 实现
题目:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After...
分类:编程语言   时间:2014-12-26 16:15:23    阅读次数:221
leetcode 【 Merge Two Sorted Lists 】 python 实现
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.代码:oj在...
分类:编程语言   时间:2014-12-26 16:08:31    阅读次数:205
leetcode Linked List Swap Nodes in Pairs python 实现
题目:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list a...
分类:编程语言   时间:2014-12-26 14:27:01    阅读次数:205
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!