As reported: Glean new grad loop (2025), round 1 (one hour with an engineer, LeetCode style): given
marrays of sizen, find the k-th largest element.
You are given m integer arrays, each of length n. Return the k-th largest value among all m · n numbers.
Example 1
arrays = [[3,1,9],[7,2,5],[8,6,4]], k = 2 -> 8
Example 2
arrays = [[5,5,1],[5,2,0]], k = 3 -> 5
Clarifications
- Duplicates count separately: in Example 2 the three largest values are
5, 5, 5. - The arrays are not necessarily sorted.
Constraints: 1 ≤ m, n; m · n ≤ 10^5; 1 ≤ k ≤ m · n; -10^9 ≤ value ≤ 10^9.
Code runner format: one JSON value per line: arrays, then k. Implement kthLargest(arrays, k); the harness prints the value.