{"id":3791,"date":"2021-04-19T20:11:50","date_gmt":"2021-04-19T12:11:50","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=3791"},"modified":"2021-04-19T20:11:50","modified_gmt":"2021-04-19T12:11:50","slug":"%e3%80%90leetcode%e3%80%91%e6%8e%92%e5%ba%8f%e9%9b%86%e9%94%a6","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/algorithm\/3791\/","title":{"rendered":"\u3010Leetcode\u3011\u6392\u5e8f\u96c6\u9526"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">L215\uff1a\u6570\u7ec4\u4e2d\u7684\u7b2cK\u4e2a\u6700\u5927\u5143\u7d20<\/h3>\n\n\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/kth-largest-element-in-an-array\/\">https:\/\/leetcode-cn.com\/problems\/kth-largest-element-in-an-array\/<\/a><\/p>\n\n\n<p>\u8fd9\u9053\u9898\u6709\u70b9\u5947\u602a\uff08\u6307\u6570\u636e\uff09\uff0c\u5176\u5b9e\u6309\u8bf4\u7b2ck\u4e2a\u5e94\u8be5\u7528\u5927\u5c0f\u5806\uff08\u590d\u6742\u5ea6N*lgK\uff09\uff0c\u4f46\u662f\u8fd9\u9053\u9898\u6392\u5e8f\uff08NlgN\uff09\u540e\u53d6\u7b2ck\u4e2a\u53cd\u800c\u66f4\u5feb\u3002<\/p>\n\n\n<p>\u5806\u4ee3\u7801\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>class Solution(object):\n    def findKthLargest(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        import heapq\n        return heapq.nlargest(k, nums)[-1]<\/code><\/pre>\n\n\n<p>\u6392\u5e8f\u4ee3\u7801\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>class Solution(object):\n    def findKthLargest(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        nums.sort()\n        return nums[-k]<\/code><\/pre>\n\n\n<p>\u7b80\u5355\u66b4\u529b\uff0c\u5374\u53c8\u4e0d\u5931\u6709\u6548\u54c8\u54c8\u54c8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>L215\uff1a\u6570\u7ec4\u4e2d\u7684\u7b2cK\u4e2a\u6700\u5927\u5143\u7d20 https:\/\/leetcode-cn.com\/problems\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"views":1974,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3791"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3791"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3791\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3791"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}