[LintCode]Find Median of Unsorted Array O(n) quick sort
来源:互联网 发布:windows xp软件功能 编辑:程序博客网 时间:2024/06/14 09:30
Easy Median
21%
Accepted
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 in the array, return the N/2-th number after sorted.
Example
Given [4, 5, 1, 2, 3], return 3
Given [7, 9, 4, 5], return 5
Challenge
O(n) time.
记忆中做过这个题目,找不到了。这次做遇到一个bug,做了很久。这个做法作为一个quick sort 的standard。 已末尾元素为pivot
另外,我一律用的是绝对坐标纪录起始与目标 位置,最后要找的位置,也是坐标。比起来找一个size, 绝对坐标是不变的, 更方便, 不需要在右半边情况时候,重新计算size了。
0 0
- [LintCode]Find Median of Unsorted Array O(n) quick sort
- Find the median of 2 sort ed array.
- Find the k-th minimal element of an unsorted array
- Google/LintCode:H-Median of two Sorted Array
- 经典题find median of two sorted array
- Median of Two Sorted Arrays O(log (m+n))
- Give an O(lg n)-time algorithm to find the median of all 2n elements in arrays X and Y.
- LeetCode, Median of Two Sorted Arrays, Java Solution, O(m+n), O(log(m+n))
- LintCode Kth Smallest Number in A Unsorted Array
- [LinkedIn]find balance (equilibrium) point (index) in an array (unsorted)
- Find the kth largest element in an unsorted array
- Find the smallest positive number missing from an unsorted array
- Median of Two Sorted Array
- Median of two sorted array
- median of two sorted array
- median of two sorted array
- LeetCode-Median of sorted array
- Median of 5 element array.
- C++基础——对函数模板的类型推导的补充
- 欢迎使用CSDN-markdown编辑器
- windows下dmp抓取方法总结
- php面向对象学习(1)
- STM8 通用输入输出口(GPIO)
- [LintCode]Find Median of Unsorted Array O(n) quick sort
- GPIO口超强总结
- 安卓单元测试InstrumentationTestRunner
- 算法-排序-交换排序(冒泡和快速排序)
- SpringMVC 的2个配置问题
- 【摄影】【夜景】拍摄注意事项
- js 替换反斜杠(\)
- play 集成squeryl ORM持久化框架
- ps人物换脸移花接木