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. vue项目--vuex状态管理器

    本文取之官网和其他文章结合自己的理解用简单化的语言表达.用于自己的笔记记录,也希望能帮到其他小伙伴理解,学习更多的前端知识. Vuex 是什么? Vuex 是一个专为 Vue.js 应用程序开发的状态 ...

  2. 72. Edit Distance (JAVA)

    Given two words word1 and word2, find the minimum number of operations required to convert word1 to  ...

  3. Git 操作 GitHub

    Git安装 https://www.cnblogs.com/taopanfeng/p/11076702.html 设置用户名(设置一次 以后就不用再设置了) git config --global u ...

  4. nodejs express 上传文件自定义文件名和上传路径

    1.客户端 <form action="http://localhost:3000/profile" method="post" enctype=&quo ...

  5. 解决deepin没有ll等命令的办法

    编辑~/.bashrc, 添加alias 如下 vim ~/.bashrc 设置别名. 添加如下行 alias ll='ls -alF' alias la='ls -A' alias vi='vim' ...

  6. 生成不带版本的jar包 不影响deploy

    1 How to build maven project without version? 工程pom中增加 <project> ... <build> ... <fin ...

  7. __name__='main' 这句代码是什么意思?《读书笔记》

    当我们阅读 别人的python代码都会有 if name == "main"这么一行语句,但却不知道为什么要写这个?有什么用 想知道这段代码什么意思让我们来根据例子来测试一下 我们 ...

  8. 一张图明白jenkins和docker作用

    可以看出,jenkins充当的是一个自动构建的作用,构建完后自动部署到机器上.如果没有docker,那么就是直接把打包好的jar包直接部署到服务器.现在是把jar包部署到服务器上的docker容器上. ...

  9. chrome 开发者工具 - local overrides

    使用chrome 作为本地网络服务 chrome 65+ 新功能, 使用我们自己的本地资源覆盖网页所使用的资源,可以使用本地css文件覆盖网页的css文件,修改样式. 类似的,使用DevTools的工 ...

  10. HDU-3416-MarriageMatch4(最大流,最短路)

    链接: https://vjudge.net/problem/HDU-3416 题意: Do not sincere non-interference. Like that show, now sta ...