e******y 发帖数: 13 | 1 面试结束了,不过对这两个问题比较感兴趣,所以想问问:
1)一个C++问题。函数有没有可能返回一个const指针或者变量?
2)有10亿个数字,怎么可以找出前10000个最大的数字?要考虑到内存一次存不下那10
亿个数字。 | j******n 发帖数: 271 | 2 1. 可以吧。
2. Keep a sorted container (e. g. a heap) of size 10000;
scan the 10B numbers and for each one, compare it with the smallest one in
the sorted container, swap it if it > smallest from container. |
|