반응형
Recent Posts
Notice
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- python 2309
- 항해99
- 백준 2309
- BOJ
- easy 딥러닝
- 큐
- 활성화 함수
- leetcode
- til
- 99항해
- softeer
- 구현
- 혁펜하임
- BFS
- 개발자 취업
- 스택
- 코딩테스트준비
- Python
- dfs
- 코딩테스트 준비
- boj 2309
- 해시
- 파이썬
- 백준
- 개발자취업
- 99클럽
- 딥러닝
- 프로그래머스
- 기능개발
- 알고리즘
Archives
- Today
- Total
동까의 코딩
[99클럽] 13일차 TIL 본문
반응형
leetcode에서 그래프문제를 풀어보았습니다.
아직도 leetcode 문제풀이는 너무 어렵습니다..
https://leetcode.com/problems/all-paths-from-source-to-target/description/
class Solution:
def __init__(self):
self.paths = []
self.graph = {}
def buildGraph(self, graph):
for i, neighbors in enumerate(graph):
self.graph[i] = neighbors
def setPaths(self, src, dest, path):
if src == dest:
self.paths.append(path)
return
for neighbor in self.graph[src]:
self.setPaths(neighbor, dest, path + [neighbor])
def allPathsSourceTarget(self, graph: List[List[int]]) -> List[List[int]]:
self.buildGraph(graph)
self.setPaths(0, len(graph)-1, [0])
return self.paths반응형
'문제 풀이 > 99클럽' 카테고리의 다른 글
| [99클럽] 15일차 TIL (0) | 2024.06.04 |
|---|---|
| [99클럽] 14일차 TIL (0) | 2024.06.03 |
| [99클럽] 12일차 TIL (1) | 2024.06.01 |
| [99클럽] 11일차 TIL (0) | 2024.05.31 |
| [99클럽] 10일차 TIL (0) | 2024.05.30 |