当前位置:网站首页>数组中的第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];
}
}
边栏推荐
- Caché WebSocket
- 6.26cf simulation match B: solution to array reduction problem
- Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
- Perfect JS event delegation
- 建立自己的网站(15)
- Digital "new" operation and maintenance of energy industry
- Scala basic tutorial -- 20 -- akka
- ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
- 6.26cf simulation race e: solution to the problem of price maximization
- 神经网络物联网应用技术学什么
猜你喜欢

Go微服务(二)——Protobuf详细入门

My colleagues quietly told me that flying Book notification can still play like this

Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg

神经网络物联网应用技术学什么

Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines

Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers

Halcon模板匹配

整理混乱的头文件,我用include what you use

Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join

千万不要只学 Oracle、MySQL!
随机推荐
李迟2022年6月工作生活总结
神经网络物联网应用技术就业前景【欢迎补充】
读写关闭的channel是啥后果?
Using FTP
启牛开的证券账户安全吗?
6.26CF模拟赛E:价格最大化题解
php伪原创api对接方法
Mxnet implementation of googlenet (parallel connection network)
File processing examples of fopen, FREAD, fwrite, fseek
【2022年江西省研究生数学建模】水汽过饱和的核化除霾 思路分析及代码实现
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
Li Kou brush question diary /day3/2022.6.25
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
1、 Introduction to C language
Scala基础教程--14--隐式转换
性能优化之关键渲染路径
Lex and yacc based lexical analyzer + parser
Scala basic tutorial -- 19 -- actor
Wireshark抓包TLS协议栏显示版本不一致问题