Solve with cache