Ctrl K

K-th Biggest Long Number

Medium
You get an array of strings numbers, each the decimal form of a non-negative integer with no leading zeros. The numbers can be very long, up to 100 digits. Return the string holding the k-th largest number (k = 1 is the largest). Repeated numbers count separately: in ["7", "7", "2"] the second largest is "7".
Example 1
numbers=["905", "88", "1200", "77"], k=2 → '905'

In decreasing order: 1200, 905, 88, 77, so the second is "905". Comparing as text fails here: "88" > "1200" alphabetically.

Example 2
numbers=["5", "5", "3"], k=2 → '5'

Equal numbers count separately: the first and second largest are both 5s.

Example 3
numbers=["0"], k=1 → '0'
Constraints
  • 1 ≤ k ≤ len(numbers) ≤ 10⁴
  • 1 ≤ len(numbers[i]) ≤ 100
  • numbers[i] consists of digits only
  • No leading zeros (except for the number "0" itself)
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsK-th Code by Its Last Digits MediumK-th Highest Score MediumMost Common Values MediumNearest Points to the Base MediumK-th Largest Corner XOR Medium
loading Python…
Input
numbers=["905", "88", "1200", "77"], k=2
Expected
'905'

Run checks the first 3 tests in your browser. Submit checks all 114 tests on the server, hidden ones included.