码迷,mamicode.com
首页 >  
搜索关键字:merge k sorted lists    ( 11722个结果
[LeetCode] Merge Two Sorted Lists
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.public cl...
分类:其他好文   时间:2014-08-29 01:16:36    阅读次数:267
归并排序
归并排序的核心思想是分治原则:即将问题分解、解决、合并。问题分解师将n个元素分成n/2个元素的子序列;问题解决是用合并排序法对两个子序列进行递归排序;问题合并是利用已排好的两个子序列合并为新的序列,得到排序结果。可以看出,对已序序列的合并是问题关键。 1.合并已序序列:过程用图来表示吧! #define INFTY 2147483647 void Merge(int a[],int low,i...
分类:其他好文   时间:2014-08-29 00:09:46    阅读次数:278
【LeetCode】- Merge Sorted Array (合并有序数组)
[ 问题: ] Given two sorted integer arrays A and B, merge B into A as one sorted array. 直译:给定两个排好序的整形数组,将数组B合并到数组A,形成一个新的有序数组。...
分类:其他好文   时间:2014-08-28 14:53:19    阅读次数:214
Search a 2D Matrix【python】
class Solution: # @param matrix, a list of lists of integers # @param target, an integer # @return a boolean def searchMatrix(self, matrix...
分类:编程语言   时间:2014-08-28 11:24:19    阅读次数:216
Convert Sorted Array to Binary Search Tree & Convert Sorted List to Binary Search Tree
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.方法:将有序数组转为平...
分类:其他好文   时间:2014-08-27 23:17:18    阅读次数:278
43. Merge Sorted Array && LRU Cache
思想:因为 A 很大, 所以从最大值开始插入, 即从 A 的 m+n 位置开始插入数据。避免了冗余的移动。 思想: 1. 由于要 O(1) 时间确定某 key 是不是在 Cache 中,所以用 Hash_map (), 从而能够O(1)找到结点地址,返回对应的 value。 2. 由...
分类:其他好文   时间:2014-08-27 21:43:08    阅读次数:191
hdu--3743--归并排序<自顶向下&&自底向上>2种写法
有些人说 归并排序的递归版本实用性差 可读性强非递归版本恰好相反我觉得 也没那么明显差距吧....其实非递归版本也不难理解的假如 我们需要进行排序的数组的长度为 len 每次的子排序数组区间为size那么我们首先将它拆成 len个size为1的小区间 然后2个相邻的进行合并merge排序 这时候 你...
分类:其他好文   时间:2014-08-27 20:27:18    阅读次数:346
Permutations【python】
class Solution: # @param num, a list of integer # @return a list of lists of integers def permute(self, num): length=len(num) i...
分类:编程语言   时间:2014-08-27 20:11:28    阅读次数:200
34. Convert Sorted List to Binary Search Tree && Convert Sorted Array to Binary Search Tree
思想: 以中间点为根节点,按先序顺序来创建 。
分类:其他好文   时间:2014-08-27 18:33:28    阅读次数:248
leetcode之Search in Rotated Sorted Array,剑指offer之旋转数组的最小数字
输入一个递增数组的旋转,...
分类:其他好文   时间:2014-08-27 16:39:18    阅读次数:196
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!