Solve in linear time! I think...