mycode  77.39%

class Solution(object):
def findKthLargest(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
nums.sort()
return nums[-k]

参考

class Solution(object):
def findKthLargest(self, nums, k):
nums.sort(reverse=True)
return nums[k-1]

leetcode-mid-array-sorting and searching - 215 Kth Largest Element in an Array的更多相关文章

  1. 剑指offer 最小的k个数 、 leetcode 215. Kth Largest Element in an Array 、295. Find Median from Data Stream(剑指 数据流中位数)

    注意multiset的一个bug: multiset带一个参数的erase函数原型有两种.一是传递一个元素值,如上面例子代码中,这时候删除的是集合中所有值等于输入值的元素,并且返回删除的元素个数:另外 ...

  2. 网易2016 实习研发工程师 [编程题]寻找第K大 and leetcode 215. Kth Largest Element in an Array

    传送门 有一个整数数组,请你根据快速排序的思路,找出数组中第K大的数. 给定一个整数数组a,同时给定它的大小n和要找的K(K在1到n之间),请返回第K大的数,保证答案存在. 测试样例: [1,3,5, ...

  3. LeetCode OJ 215. Kth Largest Element in an Array 堆排序求解

    题目链接:https://leetcode.com/problems/kth-largest-element-in-an-array/ 215. Kth Largest Element in an A ...

  4. LN : leetcode 215 Kth Largest Element in an Array

    lc 215 Kth Largest Element in an Array 215 Kth Largest Element in an Array Find the kth largest elem ...

  5. 【LeetCode】215. Kth Largest Element in an Array (2 solutions)

    Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is t ...

  6. 【刷题-LeetCode】215. Kth Largest Element in an Array

    Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is t ...

  7. [LeetCode] 215. Kth Largest Element in an Array 数组中第k大的数字

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

  8. 【LeetCode】215. Kth Largest Element in an Array 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:移除最大值 方法二:排序 方法三:大顶堆 方 ...

  9. leetcode 215. Kth Largest Element in an Array

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

随机推荐

  1. LVS负载均衡常用的工作模式有NAT、DR、和TUN三种,其中DR模式性能最为优越,使用最为广泛。

    一.安装LVS LVS的编译安装参考本站文章:http://www.linuxe.cn/post-192.html,对于LVS这种功能性软件,在生产中用yum安装也是没有问题的. 1 yum inst ...

  2. 响应式前端框架Bootstrap系列(11)分页

    分页功能已经封装成一个独立的js文件,也是用bs完成的,名称为bootstrap-paginator.js. 使用前先导入文件 : <script src="../libs/boots ...

  3. paramiko模块(基于SSH用于连接远程服务器)

    paramiko模块,基于SSH用于连接远程服务器并执行相关操作 class SSHConnection(object): def __init__(self, host_dict): self.ho ...

  4. mydql 设置充许远程链接

    1 本机作为服务器时,其他机器连接不上? 1)看一下防火墙是否打开了. 2)在cmd中设置权限. 第一种:(进入数据库的情况下) 1.d:\mysql\bin\>mysql -h localho ...

  5. AIX中逻辑卷管理

    1.逻辑卷管理 逻辑卷的大小确定: 逻辑卷大小(MB)=PP的大小(MB)*LV包含的LP的个数 LV占用的物理空间(MB)=PP的大小(MB)*LV包含的LP的个数*LV拷贝的副本数   逻辑卷控制 ...

  6. Linux crontab计划任务

    1.cron计划任务的描述        cron计划任务允许用户根据“时间表”自动周期的完成任务某些任务.        cron是一种system V服务,需要开启该服务才能使用.        ...

  7. linux 查看io

    有时系统卡,可能是io值使用满了导致 1.安装iostat yum install sysstat 2.查看io使用情况 iostat -dx 3.安装iotop yum install iotop ...

  8. PAT Advanced 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  9. 使用RegisterPointerInputTarget时的一些注意事项

    RegisterPointerInputTarget :允许调用者注册一个目标窗口,指定类型的所有指针输入都重定向到该窗口. 要使用它必须使 UIAccess = true,见下图 在设置完之后,需要 ...

  10. pt-online-schema-change的用法

    pt-online-schema-change的用法 环境: 10.192.30.53 主库 10.192.30.60 从库 mysql版本:8.0.17 为了方便操作,简单的写了如下的脚本. #!/ ...