Find Kth Unique Maximum
Company: SoFi
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates algorithmic problem-solving skills related to sorted arrays, deduplication, and order-statistics across combined datasets, measuring competence with array manipulation and distinctness reasoning.
Constraints
- 0 <= len(nums1), len(nums2) <= 100000
- -1000000000 <= nums1[i], nums2[i] <= 1000000000
- Both arrays are sorted in non-decreasing order
- 1 <= k <= 200000
Examples
Input: ([1, 2, 4, 4, 5], [2, 4, 6], 1)
Expected Output: 6
Explanation: The distinct values are [6, 5, 4, 2, 1]. The 1st distinct largest value is 6.
Input: ([1, 2, 4, 4, 5], [2, 4, 6], 3)
Expected Output: 4
Explanation: The distinct values are [6, 5, 4, 2, 1]. The 3rd distinct largest value is 4.
Input: ([], [2, 2, 3, 5], 2)
Expected Output: 3
Explanation: Only nums2 contributes values. The distinct values in descending order are [5, 3, 2], so the 2nd is 3.
Input: ([1, 5, 5], [4, 5, 5], 2)
Expected Output: 4
Explanation: The value 5 appears in both arrays but must be counted once. The distinct values are [5, 4, 1], so the 2nd distinct largest value is 4.
Input: ([-5, -3, -3, -1], [-4, -3, 0], 4)