每日一题 274. H 指数

274. H 指数

排序后就很解决

cpp 复制代码
class Solution {
public:
    int hIndex(vector<int>& citations) {
        int n = citations.size();
        sort(citations.begin(),citations.end());
        int ans = 0;
        for(int i=n-1;i>=0;--i){
            int h = n- i;
            if(citations[i] >= h){
                ans = h;
            }else{
                break;
            }
        }
        return ans; 
    }
};
相关推荐
枫景Maple9 小时前
LeetCode 2297. 跳跃游戏 VIII(中等)
算法·leetcode
緈福的街口12 小时前
【leetcode】3. 无重复字符的最长子串
算法·leetcode·职场和发展
小刘不想改BUG16 小时前
LeetCode 70 爬楼梯(Java)
java·算法·leetcode
sz66cm18 小时前
LeetCode刷题 -- 542. 01矩阵 基于 DFS 更新优化的多源最短路径实现
leetcode·矩阵·深度优先
爱coding的橙子20 小时前
每日算法刷题Day24 6.6:leetcode二分答案2道题,用时1h(下次计时20min没写出来直接看题解,节省时间)
java·算法·leetcode
慢慢慢时光20 小时前
leetcode sql50题
算法·leetcode·职场和发展
pay顿20 小时前
力扣LeetBook数组和字符串--二维数组
算法·leetcode
岁忧20 小时前
(nice!!!)(LeetCode每日一题)2434. 使用机器人打印字典序最小的字符串(贪心+栈)
java·c++·算法·leetcode·职场和发展·go
Tisfy20 小时前
LeetCode 2434.使用机器人打印字典序最小的字符串:贪心(栈)——清晰题解
leetcode·机器人·字符串·题解·贪心·