码迷,mamicode.com
首页 >  
搜索关键字:merge k sorted lists    ( 11722个结果
#Leet Code# Permutation
描述:输出全排列代码: 1 class Solution: 2 # @param num, a list of integer 3 # @return a list of lists of integers 4 def doSth(self, num): 5 ...
分类:其他好文   时间:2014-08-11 17:10:32    阅读次数:205
[LeetCode]Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). public class Solution { ...
分类:其他好文   时间:2014-08-11 15:14:12    阅读次数:188
jquery 数组求差集,并集
var alpha = [1, 2, 3, 4, 5, 6], beta = [4, 5, 6, 7, 8, 9];$.arrayIntersect = function(a, b){ return $.merge($.grep(a, function(i) { ...
分类:Web程序   时间:2014-08-11 11:42:42    阅读次数:2321
leetcode 刷题之路 70 earch Insert Position 二分查找插入位置
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array....
分类:其他好文   时间:2014-08-10 18:48:50    阅读次数:203
DSU
DSU stands for ‘decorate, sort, undecorate’ and refers to a pattern that is often useful for sorting lists according to some attribute of elements.For...
分类:其他好文   时间:2014-08-10 18:03:30    阅读次数:204
【leetcode】Add Two Numbers 解析以及拓展
题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Outpu...
分类:其他好文   时间:2014-08-10 13:08:30    阅读次数:296
快速排序 归并排序的非递归版本 备忘
首先,归并排序,分治,递归解决小的范围,再合并两个有序的小范围数组,便得到整个有序的数组。 这是很适合用递归来写的,至于非递归,便是从小到大,各个击破,从而使得整个数组有序。代码如下: void merge(vector &A, int left, int mid, int right) { int i=left,j=mid+1; vector tmp(right-left+1,0);...
分类:其他好文   时间:2014-08-10 13:08:00    阅读次数:235
LeetCode--Merge Intervals
简单题:先按左左边排序,然后对输入的区间和当前结果合并 1 /** 2 * Definition for an interval. 3 * struct Interval { 4 * int start; 5 * int end; 6 * Interval() : ...
分类:其他好文   时间:2014-08-09 21:25:19    阅读次数:205
[leetcode]Search in Rotated Sorted Array
Search in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2)....
分类:其他好文   时间:2014-08-09 18:27:48    阅读次数:148
[leetcode]Search for a Range
Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ...
分类:其他好文   时间:2014-08-09 18:18:28    阅读次数:214
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!