← 返回 sofi 的题目列表Kth Unique Maximum from Two Sorted Arrays
类型:qbank
Given two ascending sorted integer arrays and `K`, return the Kth largest distinct value across both arrays.
Requirements
Input: two ascending sorted integer arrays and a number K.
Return the Kth unique maximum integer from the union of both arrays.
Duplicate values across or within arrays count once.
Examples
Array 1: 1, 2, 4, 4, 5
Array 2: 2, 4, 6
K = 1 -> 6
K = 2 -> 5
K = 3 -> 4
K = 4 -> 2
K = 5 -> 1
Notes
Work from the end of both sorted arrays and skip duplicate values as they are consumed.
Clarify behavior when K is larger than the number of unique values.