naive solution - time limit exceeded