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