a recursive solution, TLE