[leetcode]Median of Two Sorted Arrays
来源:互联网 发布:php网站源码怎么安装 编辑:程序博客网 时间:2024/06/16 04:07
题意:
①原题
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)).
②乡村英语翻译一下
给你两个排序数组,容量为m的数组A,容量为n的数组B。求出两个数组的中位数(啥玩意?),硬性要求时间复杂度O(log (m+n)).
③读题
1:太汗颜了,median到底是个啥,查一下:
中位数是在一组数据中居于中间的数(特别注意的地方是:这组数据之前已经经过升序排列!!!),即在这组数据中,有一半的数据比它大,有一半的数据比它小。如果这组数据包含偶数个数字,中值是位于中间的两个数的平均值。
2:好吧,中位数是这么个玩意,那么理论上首先我们需要先将两个数组合为一,再求这个新合并的数组的中位数。
3:但是,已经限定死了时间复杂度为log(m+n),原来LeetCode的题目也思路不开放嘛。
4:问题可以转化成两个有序序列找第num大的数,由于时间复杂度已经限定死了,只能采用类似二分的思想,每个步骤去掉一半数据元素。
0 0
- LeetCode: Median of Two Sorted Arrays
- LeetCode Median of Two Sorted Arrays
- leetcode 26: Median of Two Sorted Arrays
- Leetcode 4 Median of Two Sorted Arrays
- [Leetcode] Median of Two Sorted Arrays
- LeetCode 4 - Median of Two Sorted Arrays
- [LeetCode]Median of Two Sorted Arrays
- leetcode Median of Two Sorted Arrays
- LeetCode-Median of Two Sorted Arrays
- [LeetCode] Median of Two Sorted Arrays
- [LeetCode] Median of Two Sorted Arrays
- [leetcode] Median of Two Sorted Arrays
- leetcode-004:Median of Two Sorted Arrays
- Leetcode 4 Median of Two Sorted Arrays
- leetcode之 median of two sorted arrays
- 【转载】【leetcode】Median of Two Sorted Arrays
- LeetCode - Median of Two Sorted Arrays
- [LeetCode]Median of Two Sorted Arrays
- Qt5学习之路(vs2012下创建一个QT应用程序)2013-10-14
- 利用Action的常用Intent跳转
- js函数参数设置默认值
- [Android] Duplicate id @+id/xxx, already defined earlier in this layout
- jquery中attr和prop的区别
- [leetcode]Median of Two Sorted Arrays
- C语言中标准内存分配函数
- png,或jpg等等图片格式和webp图片格式互相转换的在线工具
- CSP开发基础--CSP开发流程
- centos下搭建单机和伪分布式hadoop环境-(1)写在前面
- 核函数方法简介
- 【Rayeager PX2分享】OpenCV入门之图像缩放
- 数据表和视图的关系和区别
- 什么是云计算