일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Generator
- 운영체제
- 밴픽
- 프로그래머스
- kaggle
- concurrency
- 30. Substring with Concatenation of All Words
- shiba
- LeetCode
- 시바견
- Convert Sorted List to Binary Search Tree
- Python Code
- Class
- 43. Multiply Strings
- 파이썬
- 315. Count of Smaller Numbers After Self
- t1
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- attribute
- 컴퓨터의 구조
- Regular Expression
- DWG
- Decorator
- iterator
- Protocol
- data science
- 715. Range Module
- Python
- Python Implementation
Archives
- Today
- Total
목록Reorder Routes to Make All Paths Lead to the City Zero (1)
Scribbling
LeetCode: 1466. Reorder Routes to Make All Paths Lead to the City Zero
DFS로 쉽게 풀 수 있다. class Solution: def minReorder(self, n: int, connections: List[List[int]]) -> int: self.graph = [[] for _ in range(n)] self.connections_set = set() for u, v in connections: self.graph[u].append(v) self.graph[v].append(u) self.connections_set.add((u, v)) visited = [False] * n self.ret = 0 self.dfs(0, visited) return self.ret def dfs(self, node, visited): visited[node] = True for v..
Computer Science/Coding Test
2021. 11. 23. 17:52