【解题报告】lintcode5寻找第k大数

题意

寻找给定无序数组中第k大的数

解法

设置一个标记数组,扫描给出的数组,在标记数组对应下标的数字上加一
然后遍历标记数组,当综合等于给出数组长度-k时,就找到了第k大数(此时标记数组的下标就是这个数字)

代码

u3coding
A software developer

Leave a Comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.