Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
	class SolutionTest {
        List<List<Integer>> result = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        public int[] findRedundantConnection(int[][] edges) {
            for (int i = 0; i < edges.length; i++) {
                dfs(edges, i);
            }

        }

        private void dfs(int[][] edges, int i) {
            path.add(i);
            if (edges.length == i) {
                result.add(new ArrayList<>(path));
                return;
            }

            for (int j = 0; j < edges[i].length; j++) {
                dfs(edges, j);
            }

            path.remove(path.size() - 1);
        }
    }


크루스칼 알고리즘?..

https://jcsoohwancho.github.io/2019-10-26-%EC%83%81%ED%98%B8-%EB%B0%B0%ED%83%80%EC%A0%81-%EC%A7%91%ED%95%A9-union-find/