Auto Saved.

215. Kth Largest Element in an Array

Loading Question ...
  • Total Accepted: 118864
  • Total Submissions: 311001
  • Difficulty: Medium
  • Contributors: Admin

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

For example,
Given [3,2,1,5,6,4] and k = 2, return 5.

Note:
You may assume k is always valid, 1 ≤ k ≤ array's length.

Credits:
Special thanks to @mithmatt for adding this problem and creating all test cases.

Subscribe to see which companies asked this question.

Have you met this question in a real interview?
Yes
No
When did you meet this question?
last week
last month
last 3 month
last 6 month
more than 6 months
other
Which company asked you this question?
Adobe
Aetion
Affirm
Airbnb
Alation
Alibaba
Amazon
AppDynamics
Apple
Arista
Baidu
Bank of America
BlackRock
Blend Labs
Blizzard
Bloomberg
Booking
Box
Bungie
Capital One
CareerBuilder
Cisco
Citadel
Coinbase
Concur
Conviva
Coupang
Coursera
CreditEase
CVTE
Dell
Deutsche Bank
DoorDash
Dropbox
Duolingo
EasyNet
eBay
Electronic Arts
EMC
Epic Systems
Equinix
Evernote
Expedia
Facebook
FactSet
Fitbit
Flipkart
Fortinet
FourSquare
FreeWheel
GoDaddy
Goldman Sachs
Google
GrabTaxi
Groupon
HBO
Hedvig
HomeAway
HTC
Huawei
Hulu
IBG
IBM
Indeed
InnovatureLabs
Intel
IXL
Jane Street
JPMorgan
Jump Trading
Lending Club
LinkedIn
LiveRamp
Loovee
Marvel
Matlab
McKesson
Microsoft
Morgan Stanley
NetEase
Nintendo
Nutanix
Nvidia
Oracle
Orbitz
Palantir
Paypal
Pinterest
Pocket Gems
Point72
Qualcomm
Qualtrics
Qumulo
Quora
Rackspace
Redfin
Rubrik
Salesforce
Samsung
SAP
ServiceNow
Sina
Snapchat
SoftwareOne
Sony
SoundHound
Square
Sumologic
SurveyMonkey
Symantec
Tableau
Tencent
Tesorio
TinyCo
Tradeshift
TripAdvisor
Twilio
Twitter
Two Sigma
Uber
Veritas
Visa
VMware
Walmart
Wealthfront
Whitepages
Works Applications
Yahoo
Yandex
Yelp
Zappos
Zenefits
Zillow
Zynga
Discuss Pick One

Code editor is not supported in mobile browser.
Send Feedback