274. H-Index
2016-07-27 14:32
363 查看
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
According to the
definition of h-index on Wikipedia: "A scientist has index h if
h of his/her N papers have at least h citations each, and the other
N − h papers have no more than h citations each."
For example, given
no more than
Note: If there are several possible values for
According to the
definition of h-index on Wikipedia: "A scientist has index h if
h of his/her N papers have at least h citations each, and the other
N − h papers have no more than h citations each."
For example, given
citations = [3, 0, 6, 1, 5], which means the researcher has
5papers in total and each of them had received
3, 0, 6, 1, 5citations respectively. Since the researcher has
3papers with at least
3citations each and the remaining two with
no more than
3citations each, his h-index is
3.
Note: If there are several possible values for
h, the maximum one is taken as the h-index.
class Solution { public: int hIndex(vector<int>& citations) { sort(citations.begin(),citations.end()); int len=citations.size(); if(len==0 || citations[len-1] == 0) return 0; int count = 0; for(int i=citations.size()-1;i>=0;--i) { if(citations[i]>count) { count++; } else { break; } } return count; } };
相关文章推荐
- Android微信分享和邮件分享
- 什么是威胁情报以及它如何有助于识别安全威胁
- 从MySQL全库备份中恢复某个库和某张表
- poj 3278 Catch That Cow
- 【学习】js学习笔记:数组(一)
- IEEE 802
- AJax 跨域问题
- IEEE 802
- 在英文版操作系统中安装的MS SQL server,中文字段无法匹配
- 解压缩
- ios 银行卡号或身份证号按一定的个数分开显示
- Boost python 编程记录
- Android/Intent的使用
- 笔记9 Notification Notification创建、发送通知及取消通知
- Netperf - 网络性能测量工具
- tony的js学习笔记--事件委托
- ios加载图片内存优化
- cocos2dx-js 背景透明
- Security Configuration and Auditing Scripts for Oracle E-Business Suite (文档 ID 2069190.1)
- margin-top使用需要注意的地方