naive solution (3497984b, 69ms)
binary search implementation (4030464b, 99ms)