Find the k-th largest element
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
## Problem
Given an integer array `nums` and an integer `k`, return the **k-th largest** element in the array.
Notes:
- “k-th largest” means the element that would appear at index `k-1` if the array were sorted in **descending** order.
- You must handle duplicates correctly (e.g., `[5,5,4]`, `k=2` → answer `5`).
## Input
- `nums`: array of integers
- `k`: integer where `1 <= k <= len(nums)`
## Output
- The k-th largest element (an integer).
## Constraints (typical interview scale)
- `1 <= n <= 2 * 10^5`
- `-10^9 <= nums[i] <= 10^9`
## Example
- `nums = [3,2,1,5,6,4], k = 2` → answer `5`
Quick Answer: This question evaluates a candidate's understanding of selection algorithms and array manipulation, focusing on order statistics and correct handling of duplicates in an unsorted integer array.