greedy, dfs