H 指数-vector

274. H 指数 - 力扣(LeetCode)

sort()排的是从小到大的升序

class Solution {
public:
    int hIndex(vector<int>& citations) {
        sort(citations.begin(), citations.end());
        int h = 0, i = citations.size() - 1;

        while(i >= 0 && citations[i] > h){
            h++;
            i--;
        }
        return h;
    }
};

相关推荐

  1. 数组|274. H 指数

    2024-07-20 12:24:04       57 阅读
  2. [leetcode 274][H指数]

    2024-07-20 12:24:04       36 阅读
  3. 274. H 指数

    2024-07-20 12:24:04       29 阅读
  4. leetcode274H指数

    2024-07-20 12:24:04       25 阅读
  5. 论文引用h指数

    2024-07-20 12:24:04       28 阅读
  6. <span style='color:red;'>vector</span>

    vector

    2024-07-20 12:24:04      29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-20 12:24:04       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-20 12:24:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-20 12:24:04       45 阅读
  4. Python语言-面向对象

    2024-07-20 12:24:04       55 阅读

热门阅读

  1. 很详细!接口使用教程(二)

    2024-07-20 12:24:04       19 阅读
  2. 分布式Session共享的5类技术方案,与优劣势比较

    2024-07-20 12:24:04       16 阅读
  3. 火星地图插件

    2024-07-20 12:24:04       19 阅读
  4. 白骑士的PyCharm教学目录

    2024-07-20 12:24:04       18 阅读
  5. Mathematical Problem

    2024-07-20 12:24:04       15 阅读
  6. 第六章 Spring框架深入学习(2023版本IDEA)

    2024-07-20 12:24:04       14 阅读
  7. IO文件流

    2024-07-20 12:24:04       15 阅读