Sort a linked list in O(n log n) time using constant space complexity.merge sort、heap sort和quick sort都是O(nlgn),但是mergesort和quicksort都是递归的,不是constant s...
分类:
其他好文 时间:
2014-07-06 21:07:41
阅读次数:
210
它的思想是将一个无序的数组先用递归进行二分,当分解为无限小时,即为单个整数时,再对其进行排列。得出有序的数组 代码如下: package com.jll.sort; public class MergeSort { public MergeSort() { } public void merge(i...
分类:
其他好文 时间:
2014-07-06 21:01:33
阅读次数:
161
把一个排好序的vector转换为一颗二分查找树。很简单的题目,递归即可,保证边界不要出错。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; ...
分类:
其他好文 时间:
2014-07-06 12:53:50
阅读次数:
174
For the exercises in this chapter we need a list of English words. There are lots of word lists available on the Web, but the most suitable for our pu...
分类:
其他好文 时间:
2014-07-05 22:45:55
阅读次数:
545
Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题目的意思是将相交得区间合并...
分类:
其他好文 时间:
2014-07-05 22:24:49
阅读次数:
177
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:
其他好文 时间:
2014-07-05 19:10:48
阅读次数:
219
在进行SQL语句编写时,我们经常会遇到这样的问题:当存在记录时,就更新(Update),不存在数据时,就插入(Insert),oracle为我们提供了一种解决方法——Merge into ,具体语法如下:MERGEINTOtable_namealias1USING(table|view|sub_qu...
分类:
其他好文 时间:
2014-07-05 19:00:23
阅读次数:
177
USE [NationalUnion]GO/****** Object: StoredProcedure [dbo].[proc_DataSummary] Script Date: 07/03/2014 15:33:11 ******/SET ANSI_NULLS ONGOSET QUOTE...
分类:
数据库 时间:
2014-07-05 18:35:10
阅读次数:
370
一,归并排序 归并排序是建立在归并操作上的一种排序算法,它采用了分治法的思想,是一种稳定的排序算法,而且归并排序的速度仅次于快速排序。时间复杂度:O(n*logn),最坏的情况:O(n*logn),空间复杂度:O(n)。从数据就可以看出:归并排序比快速排序快很多,同样为稳定排序。 ...
分类:
其他好文 时间:
2014-07-05 11:16:20
阅读次数:
208
def IsContinuous(seq, num = 5):
zeros = 0; d = 0
seq = sorted(seq)
for i in range(num - 1):
if seq[i] == 0:
zeros += 1
continue
if seq[i] == seq[i + 1]:
return False
d += seq[i + 1]...
分类:
其他好文 时间:
2014-07-04 07:11:20
阅读次数:
171