俊介三

一天更新一点,一天积累一点

导航

2013年4月8日

摘要: 题目描述:输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。采用堆排比较好,但最后一个数据超时了?update(2013.4.16):用我面B公司时被问到的一个方法就能过,晕~~思路:类似快排的方法,每次递归地找k个数落入哪个部分。最后在sort一个这k个数就好,代码:#include <cstdio>#include <iostream>#include <algorithm>using namespace std; void partition(int*arr, int k, int 阅读全文

posted @ 2013-04-08 13:33 俊介三在前进 阅读(202) 评论(0) 推荐(0)