剑指offer - 最小的K个数
来源:互联网 发布:为何手机淘宝打不开 编辑:程序博客网 时间:2024/06/08 05:51
class Solution {public: vector<int> GetLeastNumbers_Solution(vector<int> input, int k) { vector<int> res; if(input.empty()||input.size()<k||k<=0) return res; int low=0,high=input.size()-1,mid=-1; while(mid!=(k-1)) { if(mid>(k-1)) high=mid-1; else low=mid+1; mid=Partition(input,low,high); } for(int i=0;i<=mid;i++) res.push_back(input[i]); return res; } int Partition(vector<int> &n,int low,int high) { int key=n[low]; while(low<high) { while(low<high&&key<=n[high]) high--; n[low]=n[high]; while(low<high&&key>=n[low]) low++; n[high]=n[low]; } n[low]=key; return low; }};
0 0
- 剑指offer:最小的k个数
- 【剑指offer】最小的k个数
- 剑指offer-30:最小的k个数
- 最小的k个数(剑指offer)
- 剑指offer--最小的K个数
- 剑指Offer之 - 最小的k个数
- 剑指offer-30 最小的K个数
- 剑指offer之最小的k个数
- 剑指offer 30 - 最小的k个数
- 《剑指offer》最小的K个数
- 【剑指Offer】最小的K个数
- 剑指offer—最小的K个数
- 剑指Offer-30-最小的k个数
- 剑指offer:最小的K个数
- 【剑指offer】之最小的k个数
- [剑指offer:30]最小的k个数
- 剑指offer 29 最小的k个数
- 剑指offer 最小的K个数
- popupWindow从下往上弹出效果的实现
- Linux桥接模式下手动配置网卡
- 贪心算法
- linux下安装python图像库PIL
- S3C2440--LCD理论
- 剑指offer - 最小的K个数
- HDU 1902 The Dragon of Loowater 贪心
- Insert Delete GetRandom O(1)
- 图像算法---磨皮算法研究汇总
- hdu 5802 Windows 10 (贪心)
- 分支限界法
- Maven项目的搭建
- 2016 Multi-University Training Contest 6
- jsp经典代码段