leetcode 274H-index
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的更多相关文章
- [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 ...
- LeetCode Minimum Index Sum of Two Lists
原题链接在这里:https://leetcode.com/problems/minimum-index-sum-of-two-lists/description/ 题目: Suppose Andy a ...
- [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 ...
- [LeetCode] Random Pick Index 随机拾取序列
Given an array of integers with possible duplicates, randomly output the index of a given target num ...
- 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 ...
- [LeetCode] Find Pivot Index 寻找中枢点
Given an array of integers nums, write a method that returns the "pivot" index of this arr ...
- LeetCode 852. Peak Index in a Mountain Array C++ 解题报告
852. Peak Index in a Mountain Array -- Easy 方法一:二分查找 int peakIndexInMountainArray(vector<int>& ...
- Leetcode之二分法专题-852. 山脉数组的峰顶索引(Peak Index in a Mountain Array)
Leetcode之二分法专题-852. 山脉数组的峰顶索引(Peak Index in a Mountain Array) 我们把符合下列属性的数组 A 称作山脉: A.length >= 3 ...
- LeetCode 599: 两个列表的最小索引总和 Minimum Index Sum of Two Lists
题目: 假设 Andy 和 Doris 想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示. Suppose Andy and Doris want to cho ...
- [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 ...
随机推荐
- C和指针---结构和联合
一.结构 1.C提供了两种类型的聚合数据类型---数组.结构.数组是相同类型的元素集合,它的每个元素长度相同,故可以通过下标引用或指针间接访问来选择的;而结构可以把不同类型的值存储在一起,由于结构的成 ...
- Python中使用百分号占位符的字符串格式化方法中%s和%r的输出内容有何不同?
Python中使用百分号占位符的字符串格式化方法中%s和%r表示需要显示的数据对应变量x会以str(x)还是repr(x)输出内容展示. 关于str和repr的关系请见: <Python中rep ...
- 第8.29节 使用MethodType将Python __setattr__定义的实例方法与实例绑定
一. 引言 在<第7.14节Python类中的实例方法解析>介绍了使用"实例对象名.方法名 = MethodType(函数, 对象)"将动态定义的方法与实例进行绑定 在 ...
- 第13.4 使用pip安装和卸载扩展模块
一.pip指令介绍 Python 使用pip来管理扩展模块,包括安装和卸载,具体指令包括: pip install xx: 安装xx模块 pip list: 列出已安装的模块 pip install ...
- PyQt(Python+Qt)学习随笔:Qt Designer中Action关联menu菜单和toolBar的方法
1.Action关联菜单 通过菜单创建的Action,已经与菜单自动关联,如果是单独创建的Action,需要与菜单挂接时,直接将Action Editor中定义好的Action对象拖拽到菜单栏上即可以 ...
- day010|python之装饰器
装饰器02 目录 装饰器02 1 装饰器的语法糖 1.1 定义 1.2 基本使用 2 有参装饰器 2.1 基本用法 2.2 示例 3叠加多个装饰器 3.1 基本用法 3.2 示例 4 wraps装饰器 ...
- 2016 piapiapia 数组绕过
0x00.感悟 写完这道题,我感觉到了扫源码的重要性.暑假复现的那些CVE,有的就是任意文件读取,有的是任意命令执行,这些应该都是通过代码审计,得到的漏洞.也就和我们的CTF差不多了. ...
- linux常用快捷键总结
启动器:<super> 显示桌面:<super>D 文件管理器:<super>E 显示工作区:<super>S 打开终端:ctrl+alt+T 关闭窗口 ...
- john快速破解各种散列hash
0x01 john工具安装: kali系统自带的有,也可以自己安装在其他linux和windows系统上,关于安装步骤网上都有可自行百度. 0x02 john常用选项 具体的其他选项可通过john - ...
- jQuery笔记(一)
day01 - jQuery 学习目标: 能够说出什么是 jQuery 能够说出 jQuery 的优点 能够简单使用 jQuery 能够说出 DOM 对象和 jQuery 对象的区别 能够写出常用的 ...