As reported: Morgan Stanley Java developer (8.5 years of experience, Bangalore) virtual hiring drive, Mar 2026: four rounds mixing Java questions and LeetCode-style coding, in Java unless the interviewer allowed another language. Round 1, after merge intervals: the k-th largest element in an array.
Given an integer array nums and an integer k, return the k-th largest element in sorted order (not the k-th distinct element).
This is LeetCode 215 — Kth Largest Element in an Array.
Example 1
nums = [3,2,1,5,6,4], k = 2 -> 5
Example 2
nums = [3,2,3,1,2,4,5,5,6], k = 4 -> 4
Constraints: 1 ≤ k ≤ nums.length ≤ 10^5; −10^4 ≤ nums[i] ≤ 10^4.
Code runner format: one JSON value per line: nums, then k (LeetCode's test-case format). Implement findKthLargest(nums, k); the harness prints the value.