반응형
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 |
Tags
- 파이썬
- til
- leetcode
- 항해99
- 99클럽
- 프로그래머스
- easy 딥러닝
- softeer
- Python
- boj 2309
- BFS
- 스택
- 활성화 함수
- 개발자 취업
- BOJ
- python 2309
- 개발자취업
- 코딩테스트준비
- 백준 2309
- 코딩테스트 준비
- 딥러닝
- 알고리즘
- dfs
- 구현
- 큐
- 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 |