public int hIndex(int[] citations) {
/*
唠唠叨叨说了很多 其实找到一个数h,使得数组中至少有h个数大于等于这个数,
其他N-h个数小于这个数,h可能有多个,求最大的那个
*/
if (citations.length==0)
return 0;
//sort方法是将原数组排序,会改变原数组
Arrays.sort(citations);
int res = 0;
for (int i = citations.length-1; i >=0 ; i--) {
if (citations[i]>=citations.length-i)
{
res++;
}
else
break;
}
return res;
}

leetcode 274H-index的更多相关文章

  1. [LeetCode] Minimum Index Sum of Two Lists 两个表单的最小坐标和

    Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite ...

  2. LeetCode Minimum Index Sum of Two Lists

    原题链接在这里:https://leetcode.com/problems/minimum-index-sum-of-two-lists/description/ 题目: Suppose Andy a ...

  3. [LeetCode] Peak Index in a Mountain Array 山形数组的顶峰坐标

    Let's call an array A a mountain if the following properties hold: A.length >= 3 There exists som ...

  4. [LeetCode] Random Pick Index 随机拾取序列

    Given an array of integers with possible duplicates, randomly output the index of a given target num ...

  5. LeetCode 599. Minimum Index Sum of Two Lists (从两个lists里找到相同的并且位置总和最靠前的)

    Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite ...

  6. [LeetCode] Find Pivot Index 寻找中枢点

    Given an array of integers nums, write a method that returns the "pivot" index of this arr ...

  7. LeetCode 852. Peak Index in a Mountain Array C++ 解题报告

    852. Peak Index in a Mountain Array -- Easy 方法一:二分查找 int peakIndexInMountainArray(vector<int>& ...

  8. Leetcode之二分法专题-852. 山脉数组的峰顶索引(Peak Index in a Mountain Array)

    Leetcode之二分法专题-852. 山脉数组的峰顶索引(Peak Index in a Mountain Array) 我们把符合下列属性的数组 A 称作山脉: A.length >= 3 ...

  9. LeetCode 599: 两个列表的最小索引总和 Minimum Index Sum of Two Lists

    题目: 假设 Andy 和 Doris 想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示. Suppose Andy and Doris want to cho ...

  10. [LeetCode] 880. Decoded String at Index 在位置坐标处解码字符串

    An encoded string S is given.  To find and write the decoded string to a tape, the encoded string is ...

随机推荐

  1. Spring Cloud Alibaba 初体验(四) Sentinel

    一.Sentinel 下载与运行 本文使用 Sentinel 1.7.1:https://github.com/alibaba/Sentinel/releases 使用自定义端口 8089 运行 Se ...

  2. 排序--MergeSort 归并排序?

    MergeSort 's implementation MergetSort 的中心思想就是分治思想,通过解决每一个小问题来解决大问题 假设你有2个已经排好序的数组 数组[ 4 ][ 8 ] 和 数组 ...

  3. day1(ModelViewSet序列化限流排序)

    1.DRF初始化 1.认证 2.权限 3.限流 4.序列化 5.分页 6.版本  7.过滤 8.排序 1.1安装DjangoRestFramework pip install djangoresfra ...

  4. R语言无网络安装R包,彻底解决依赖问题!

    R version: 3.5.3, 3.6.3 更新日期: 2020-9-10 大家测试后多提建议哈, 有问题我会持续更新的 在工作中,我们使用的服务器通常是不能联外网的,这在安装R包的时候产生了巨大 ...

  5. Python音视频开发:消除抖音短视频Logo和去电视台标的实现详解

    ☞ ░ 前往老猿Python博文目录 ░ 一.引言 对于带Logo(如抖音Logo.电视台标)的视频,有三种方案进行Logo消除: 直接将对应区域用对应图像替换: 直接将对应区域模糊化: 通过变换将要 ...

  6. PyQt(Python+Qt)学习随笔:QScrollArea的alignment属性不起作用的原因

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 Scroll Area滚动区域提供了一个呈现在其他部件上的可滚动区域视图,对应类为QScrollAr ...

  7. PyQt(Python+Qt)学习随笔:QListView的isWrapping属性

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 QListView的isWrapping属性用于控制视图中的数据项项布局在可见区域中没有足够空间时是 ...

  8. PyQt(Python+Qt)入门:设计师中部件toolTip、statusTip、whatsThis的属性

    在Qt Designer中定义的部件,都有toolTip.statusTip.whatsThis,这些属性都是辅助提示的信息. toolTip toolTip属性设置部件的toolTip提示信息,to ...

  9. 从零开始的xxe学习

    本文介绍了一个菜鸡对xxe的一步步学习(内容多来源于大佬的博客,先感谢一波) 涉及知识点: (1)xxe 目录: 解析: 1.xxe是什么(不详解了,网上很多的) XXE(XML External E ...

  10. 「IOI2017」接线 的另类做法

    看到这题,我的第一反应是:这就是一个费用流模型?用模拟费用流的方法? 这应该是可以的,但是我忘记了怎么模拟费用流了IOI不可能考模拟费用流.于是我就想了另外一个方法. 首先我们考虑模拟费用流的模型如下 ...