[LeetCode]H-Index
发布日期:2021-11-22 02:48:58 浏览次数:2 分类:技术文章

本文共 1057 字,大约阅读时间需要 3 分钟。

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 : "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 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.

Note: If there are several possible values for h, the maximum one is taken as the h-index.

看完题目,根本不知道说的是什么?

参考:

public class Solution274 {	public int hIndex(int[] citations) {		int[] hash = new int[citations.length+1];		for(int i=0; i
citations.length){ hash[citations.length]++; } else{ hash[citations[i]]++; } } int sum=0; for(int k=citations.length; k>=0; k--){ sum+=hash[k]; if(sum>=k) return k; } return 0; }}

转载地址:https://blog.csdn.net/zxdfc/article/details/48738077 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:[LeetCode]H-Index II
下一篇:[LeetCode]Set Matrix Zeroes

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月07日 06时23分56秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

AndroidStudio_android中实现对properties文件的读写操作_不把properties文件放在assets文件夹中_支持读写---Android原生开发工作笔记238 2019-04-26
弹框没反应使用Looper解决_the caller should invoke Looper.prepare() and Looper.loop()---Android原生开发工作笔记239 2019-04-26
Command line is too long. Shorten command line for Application---微服务升级_SpringCloud Alibaba工作笔记0067 2019-04-26
AndroidStudio_android实现双击_3击_监听实现---Android原生开发工作笔记240 2019-04-26
C++_类和对象_对象特性_初始化列表---C++语言工作笔记045 2019-04-26
AndroidStudio安卓原生开发_UI高级_DrawerLayout_侧滑菜单控件---Android原生开发工作笔记120 2019-04-26
AndroidStudio安卓原生开发_UI高级_Shape的使用_虚线_直线_矩形_渐变_径向渐变_线性渐变_扫描渐变---Android原生开发工作笔记122 2019-04-26
AndroidStudio安卓原生开发_UI高级_StateListDrawable状态选择器_按钮按下和抬起显示不同颜色---Android原生开发工作笔记124 2019-04-26
kivy制作安卓APP--简单音乐播放器 2019-04-26
Angular2工程部署到Tomcat服务器,第一次访问正常,刷新浏览器后报404错误 2019-04-26
【力扣】155. 最小栈 2019-04-26
【力扣】160. 相交链表 2019-04-26
【力扣】167. 两数之和 II - 输入有序数组 2019-04-26
【力扣】168. Excel表列名称 2019-04-26
【力扣】456. 132 模式 2019-04-26
【力扣】82. 删除排序链表中的重复元素 II 2019-04-26
【剑指OFFER】 41. 数据流中的中位数 2019-04-26
【力扣】83. 删除排序链表中的重复元素 2019-04-26
【剑指OFFER】 43. 1~n 整数中 1 出现的次数 2019-04-26
【剑指OFFER】44. 数字序列中某一位的数字 2019-04-26