274. H-Index论文引用量
[抄题]:
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."
Example:
Input:citations = [3,0,6,1,5]
Output: 3
Explanation:[3,0,6,1,5]means the researcher has5papers in total and each of them had
received3, 0, 6, 1, 5citations respectively.
Since the researcher has3papers with at least3citations each and the remaining
two with no more than3citations each, his h-index is3.
Note: If there are several possible values for h, the maximum one is taken as the h-index.
[暴力解法]:
时间分析:
空间分析:
[优化后]:
时间分析:
空间分析:
[奇葩输出条件]:
[奇葩corner case]:
[思维问题]:
以为n篇文章的引用量,有什么相互关系:并没有
[一句话思路]:
[输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入):
[画图]:

[一刷]:
- 累加数组元素的时候最好用一个新的sum 变量,也不占空间。加到数组元素上容易出现范围错误。
[二刷]:
[三刷]:
[四刷]:
[五刷]:
[五分钟肉眼debug的结果]:
[总结]:
[复杂度]:Time complexity: O(就是n) Space complexity: O(n)
[英文数据结构或算法,为什么不用别的数据结构或算法]:
这题比较特殊,数组元素 = 个数(也可以理解为桶排序)
计数排序(Counting sort)是一种稳定的线性时间排序算法。
计数排序使用一个额外的数组 {\displaystyle C} C ,其中第i个元素是待排序数组 {\displaystyle A} A中值等于 {\displaystyle i} i的元素的个数。
然后根据数组 {\displaystyle C} C 来将 {\displaystyle A} A中的元素排到正确的位置。
[算法思想:递归/分治/贪心]:
[关键模板化代码]:
//for loop : add to bucket
for (int c : citations) {
if (c > n) bucket[n]++;
else bucket[c]++;
}
[其他解法]:
[Follow Up]:
排序后:
[LC给出的题目变变变]:
[代码风格] :
class Solution {
public int hIndex(int[] citations) {
//cc
if (citations == null || citations.length == 0) return 0;
//ini: bucket[n + 1] form exception
int n = citations.length;
int[] bucket = new int[n + 1];
//for loop : add to bucket
for (int c : citations) {
if (c > n) bucket[n]++;
else bucket[c]++;
}
//count from back
int count = 0;
for (int i = n; i >= 0; i--) {
count += bucket[i];
if (count >= i) return i;
}
return 0;
}
}
274. H-Index论文引用量的更多相关文章
- 275. H-Index II 递增排序后的论文引用量
[抄题]: Given an array of citations in ascending order (each citation is a non-negative integer) of a ...
- Java实现 LeetCode 274 H指数
274. H指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数).编写一个方法,计算出研究者的 h 指数. h 指数的定义: "h 代表"高引用次数"(hig ...
- Leetcode 274.H指数
H指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数).编写一个方法,计算出研究者的 h 指数. h 指数的定义: "一位有 h 指数的学者,代表他(她)的 N 篇论文中至多有 ...
- HDU-6278-Jsut$h$-index(主席树)
链接: https://vjudge.net/problem/HDU-6278 题意: The h-index of an author is the largest h where he has a ...
- ZFNet(2013)及可视化的开端
目录 写在前面 网络架构与动机 特征可视化 其他 参考 博客:blog.shinelee.me | 博客园 | CSDN 写在前面 ZFNet出自论文< Visualizing and Unde ...
- [LeetCode] 274. H-Index H指数
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
- 274 H-Index H指数
给定一位研究者的论文被引用次数的数组(被引用次数是非负整数).写一个方法计算出研究者的H指数.H-index定义: “一位科学家有指数 h 是指他(她)的 N 篇论文中至多有 h 篇论文,分别被引用了 ...
- 【论文阅读】CVPR2021: MP3: A Unified Model to Map, Perceive, Predict and Plan
Sensor/组织: Uber Status: Reading Summary: 非常棒!端到端输出map中间态 一种建图 感知 预测 规划的通用框架 Type: CVPR Year: 2021 引用 ...
- H指数
H指数是用来综合衡量学者发表论文的数量和质量的指标,若某学者共发表N篇论文,H指数是指存在h 篇论文至少每篇有h 引用量,剩下的N-h篇中,每篇都不超过h引用量 计算H指数的方法:1.排序法思路:先将 ...
随机推荐
- [LeetCode系列]3元素最近和问题的O(n^2)解法
给定一个整数数组(长度不小于3) 和 一个目标值, 从数组中找出3个元素, 使得它们的和与目标值最接近, 返回这个和. 可以认为每个输入的组合都是只有唯一解的. 解法思路参考: Finding thr ...
- 在同一服务器使用git分支建立线上 和 测试 项目
分支分配文件夹后 sourcetree 创建分支与合并 https://blog.csdn.net/qq_34975710/article/details/74469068 线上分支master 测试 ...
- Web API 路由访问设置
前段时间一直致力于MVC webapi 技术的研究,中途也遇到过好多阻碍,特别是api路由的设置和URL的访问形式,所以针对这个问题,特意做出了记录,以供日后有同样困惑的大虾们借鉴: 在Mvc WEB ...
- 【经验】实现STL算法时遇到的模板编译错误问题
在实现set_union算法时调用了自己写的copy算法,出现了以下问题. Error 1 error C2665: 'xyz_stl::__copy' : none of the 2 overloa ...
- java代码---------常用的方法indexOf()和substring()方法的小结、主要是下标都是从0开始,很重要,错了就那个差远了啊
package com.s.x; //indexOf()方法从字符起始处的第一个位子开始的位置 //substring public class Wang { public static void m ...
- [Java.Web][Servlet]常用请求头
response.setStatus(302); response.setHeader("location", "/day04/1.html"); 这段代码可以 ...
- Linux文件属性,类型,ls -lhi解释行列
Linux文件属性(描述信息) -i inode节点号 -h 人类可读 ls -lhi 1703938 drwxr-xr-x 2 rsync rsync 4.0K Jun 7 07:24 gamese ...
- submit提交表单
<!DOCTYPE html><html><head> <script src="jquery-1.3.2.min.js">< ...
- PHP字符串中的变量解析
定义字符串的时候,用单引号或者双引号都是可以的.我个人习惯是用双引号.在输出字符串的时候,若字符串中含有字符串变量,使用单引号和双引号则是有区别的.如下面程序: <?php $website = ...
- CentOS7 tar打包工具 打包,解包,打包压缩,打包解压缩
tar命令 選項與參數: -c :建立打包檔案,可搭配 -v 來察看過程中被打包的檔名(filename) -t :察看打包檔案的內容含有哪些檔名,重點在察看『檔名』就是了: -x :解打包或解壓縮的 ...