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