当前位置:网站首页>数组中的第K个最大元素
数组中的第K个最大元素
2022-07-04 17:39:00 【charlsdm】
- 数组中的第K个最大元素
给定整数数组 nums 和整数 k,请返回数组中第 k 个最大的元素。
请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。
示例 1:
输入: [3,2,1,5,6,4] 和 k = 2
输出: 5
示例 2:
输入: [3,2,3,1,2,4,5,5,6] 和 k = 4
输出: 4
我的C#AC代码` public partial class Solution
{
public int FindKthLargest(int[] nums, int k)
{
List<int> mynums = nums.ToList();
mynums.Sort();
mynums.Reverse();
return mynums[k-1];
}
}
边栏推荐
- IBM WebSphere MQ检索邮件
- 6.26cf simulation race e: solution to the problem of price maximization
- 正则替换【JS,正则表达式】
- Scala basic tutorial -- 19 -- actor
- [uniapp] uniapp development app online Preview PDF file
- Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
- [2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
- Mxnet implementation of googlenet (parallel connection network)
- 神经网络物联网平台搭建(物联网平台搭建实战教程)
- Scala basic tutorial -- 20 -- akka
猜你喜欢
Li Kou brush question diary /day7/6.30
What if the self incrementing ID of online MySQL is exhausted?
【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
Torchdrug tutorial
[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation
奥迪AUDI EDI INVOIC发票报文详解
力扣刷题日记/day2/2022.6.24
Li Kou brush question diary /day3/2022.6.25
神经网络物联网应用技术学什么
随机推荐
一、C语言入门基础
力扣刷題日記/day6/6.28
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
SSL证书续费相关问题详解
Technology sharing | interface testing value and system
ThreadLocal原理与使用
完善的js事件委托
Scala basic tutorial -- 19 -- actor
读写关闭的channel是啥后果?
2022年字节跳动日常实习面经(抖音)
Using FTP
基于lex和yacc的词法分析器+语法分析器
基于unity的愤怒的小鸟设计
TorchDrug教程
Pb extended DLL development (super chapter) (VII)
使用SSH
Basic tutorial of scala -- 16 -- generics
一种将Tree-LSTM的强化学习用于连接顺序选择的方法
Torchdrug tutorial
Scala基础教程--15--递归