Find the Kth Largest in Two Sorted Arrays
GleanSoftware Engineer · Technical ScreenLast updated
This question evaluates proficiency with array manipulation and selection algorithms, specifically understanding order statistics and working with two sorted sequences.
You are given two arrays sorted in ascending order and an integer k. Return the kth largest element among all elements from both arrays combined.
Count duplicates as separate elements.
Example:
a = [0, 1, 4, 5, 6, 7, 8, 10, 13]b = [1, 3, 4, 5, 8, 9, 11, 12]k = 3
The combined elements in descending order begin with 13, 12, 11, 10, ..., so the answer is 11.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.