这道题是我最初刷的那20多道之一,但一直没有过,被各种各样的情况折磨死了,直到把所有其他的题都写完,回来看大神对这道题是怎么处理的时候,才惊叹算法的奇妙。再次验证了我的想法,如果要处理各种各样的特殊情况,一定是算法本身有问题。
之前看过很多有关在两个排序数组中找中位数的解法,大多根据两个数组长度不同分了很多种情况,各种讨论。下面要介绍的方法并没有直接求中位数,而是把求中位数转换成了求两个数组合并...
分类:
其他好文 时间:
2014-05-15 12:21:05
阅读次数:
273
leetCode-002 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)).
【题意】
有两个有序的数组,找出这两数组整合后的中位数,要求时间复杂度O(nlogn)...
分类:
其他好文 时间:
2014-05-15 04:42:05
阅读次数:
274
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 ...
分类:
其他好文 时间:
2014-05-09 23:26:18
阅读次数:
353
题目大意:
添加和删除一个数,然后输出中位数。
简单的Splay 维护Splay上有多少个节点就可以了
#include
#include
#define inf 1LL<<60
#define maxn 222222
#define keyTree (ch[ch[root][1]][0])
using namespace std;
typedef long...
分类:
其他好文 时间:
2014-05-07 07:46:42
阅读次数:
405
In this problem you will perform median filtering to enhance the quality of a noise corrupted
image. Recall from the video lecture that median filtering is effective for removing "salt-and-pepper" n...
分类:
其他好文 时间:
2014-05-07 07:20:09
阅读次数:
326
一 线性表
1.1 数组
1.1.1 Remove Duplicates from Sorted Array
1.1.2 Remove Duplicates from Sorted Array II
1.1.3 Search in Rotated Sorted Array
1.1.4 Search in Rotated Sorted Array II
1.1.5 Median of...
分类:
其他好文 时间:
2014-05-07 04:24:26
阅读次数:
363
Factorial Problem in Base K
Time Limit: 2 Seconds Memory Limit: 65536 KB
How many zeros are there in the end of s! if both s and s! are written in base k which is not necessarily to be 10...
分类:
其他好文 时间:
2014-05-02 20:11:29
阅读次数:
376
题目: 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...
分类:
其他好文 时间:
2014-04-29 10:32:46
阅读次数:
359