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. 老猿学5G扫盲贴:移动边缘计算(Mobile Edge Computing, MEC)

    版权声明:本文为CSDN博主「魏晓蕾」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/gongxifaca ...

  2. 第9.11节 Python中IO模块文件打开读写操作实例

    为了对前面学习的内容进行一个系统化的应用,老猿写了一个程序来进行文件相关操作功能的测试. 一. 测试程序说明 该程序允许测试人员选择一个文件,自己输入文件打开模式.写入文件的位置以及写入内容,程序按照 ...

  3. PyQt(Python+Qt)学习随笔:Qt Designer中QAbstractButton派生按钮部件的shortcut 属性

    shortcut 属性保存与按钮关联的快捷键.可以使用shortcut()和setShortcut(QKeySequence)访问和设置该属性. 关于这个属性官网介绍的不多,经老猿实际验证,它与tex ...

  4. Python Flask后端异步处理(二)

    在实际的应用场景中,如用户注册,用户输入了注册信息后,后端保存信息到数据库中,然后跳转至登录界面,这些操作用户需要等待的时间非常短,但是如果是有耗时任务,比如对输入的网址进行漏洞扫描,在后端处理就会花 ...

  5. 精品软件-OfficeBox办公神器

    办公文档office处理套件,非常齐全,小巧! 官方地址:http://www.wofficebox.com/

  6. 大白话详解大数据hive知识点,老刘真的很用心(2)

    前言:老刘不敢说写的有多好,但敢保证尽量用大白话把自己复习的内容详细解释出来,拒绝资料上的生搬硬套,做到有自己的了解! 1. hive知识点(2) 第12点:hive分桶表 hive知识点主要偏实践, ...

  7. Oracle 要慌了!华为终于开源了自家的 Huawei JDK——毕昇 JDK!

    没错,自阿里.腾讯之后,华为也终于开源了自家的 JDK--毕昇 JDK! 免费!免费!免费!!! Oracle 要慌了? 毕昇 JDK 毕昇 JDK 是华为内部 OpenJDK 定制版 Huawei ...

  8. 浅谈JAVA代码优化

    JAVA代码的优化分为两个方面: 一.减小代码的体积.二.提高代码的执行效率. ============================================================ ...

  9. matplotlib的学习15-次坐标轴

    import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 10, 0.1) y1 = 0.05 * x**2 y2 = - ...

  10. 被 Pandas read_csv 坑了

    被 Pandas read_csv 坑了 -- 不怕前路坎坷,只怕从一开始就走错了方向 Pandas 是python的一个数据分析包,纳入了大量库和一些标准的数据模型,提供了高效地操作大型数据集所需的 ...