O(m + n):Note:return rec[1] not rec[0]. 1 class Solution { 2 public: 3 double findMedianSortedArrays(int A[], int m, int B[], int n) { 4 i...
分类:
其他好文 时间:
2015-03-21 06:23:31
阅读次数:
103
problem:
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)).
thinking:
(1)求中位数,就是求已...
分类:
其他好文 时间:
2015-03-16 21:26:18
阅读次数:
162
Given a unsorted array with integers, find the median of it. A median is the middle number of the array after it is sorted. If there are even numbers ...
分类:
其他好文 时间:
2015-03-16 06:14:57
阅读次数:
119
题目:median of two sorted arrays
知识点:二分查找,中位数定义
public class Solution {
/*
* 关于:leetcode 第二题 给定两个排好序的数组,找到它们的中位数,要求:时间复杂度o(log(m+n));
* 变形:找第k个数
* 方法:1.遍历,时间复杂度为o(m+n),从头开始分别遍历两数组的数,按照大小计数...
分类:
其他好文 时间:
2015-03-16 01:01:30
阅读次数:
172
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 ...
分类:
其他好文 时间:
2015-03-15 12:13:53
阅读次数:
112
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 ...
分类:
其他好文 时间:
2015-03-14 21:40:42
阅读次数:
134
题目要求: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 shoul...
分类:
其他好文 时间:
2015-03-11 21:30:30
阅读次数:
123
尼玛,数组偶数个数的时候取中位数是取中间两者中的前者,还tmd一直再算平均,卧槽#include #include #include #include using namespace std;int min(int a, int b) { return a a(na); for ...
分类:
其他好文 时间:
2015-03-10 17:01:03
阅读次数:
123
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 ...
分类:
其他好文 时间:
2015-03-09 15:52:47
阅读次数:
92
LeetCode(3) || Median of Two Sorted Arrays题记之前做了3题,感觉难度一般,没想到突然来了这道比较难的,星期六花了一天的时间才做完,可见以前基础太差了。题目内容There are two sorted arrays A and B of size m and ...
分类:
其他好文 时间:
2015-03-08 00:03:19
阅读次数:
222