Solution to the type ahead problem.