일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Convert Sorted List to Binary Search Tree
- Generator
- 30. Substring with Concatenation of All Words
- 프로그래머스
- 밴픽
- t1
- Class
- 파이썬
- 715. Range Module
- concurrency
- LeetCode
- 315. Count of Smaller Numbers After Self
- Substring with Concatenation of All Words
- Protocol
- attribute
- data science
- Python Implementation
- Decorator
- DWG
- Python Code
- 컴퓨터의 구조
- kaggle
- Regular Expression
- iterator
- 109. Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- 운영체제
- 시바견
- Python
- shiba
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