Solution to LeetCode Median of Two Sorted Arrays problem.
The solution and its proof are non-trivial, so I would refer you to “Pearls of Functional Algorithm Design”, chapter “A Selection Problem” for an in-depth explanation of computing this. The algorithm there gives us a general way to compute the \(k\)’th smallest number given two sorted arrays. The algorithm is quite neat, although this array version unfortunately suffers from indexitis – there are a lot of indices floating around.