# LeetCode 2 – Median of Two Sorted Arrays

#### Posted on December 21, 2013

##### Last updated on December 21, 2013

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.

Markdown SHA1: 6902a9f101f880060b722e8212f6b31197530bbc