use stack to store results and numbers
Avoid useless dfs to avoid TLE