알고리즘62 tree - dfs 간선 정보가 주어진 경우, 트리를 생성할 수 있다. 트리 순회가 필요한 경우, dfs()로 문제해결할 수 있다. 간선정보 : (u, v) 트리 생성 : tree[u][v] = true, tree[v][u] = true // tree[u].push_back(v), tree[v].push_back(u) // dfs() : visit[] or parent 값으로 continue 조정. for (child : tree[u]) if (visit[child]) continue; 2021. 4. 21. leetcode - Find the Town Judge - easy https://leetcode.com/problems/find-the-town-judge/ Find the Town Judge - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public: int findJudge(int n, vector& trust) { vector first_(n+1); vector second_(n+1); int size = trust.size(); for (int i = 0; i < size; ++i) {.. 2020. 9. 22. 이전 1 ··· 13 14 15 16 다음