반응형
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
- 기능개발
- 구현
- softeer
- 딥러닝
- 99항해
- 개발자취업
- boj 2309
- 알고리즘
- til
- 99클럽
- 코딩테스트 준비
- 파이썬
- 스택
- leetcode
- python 2309
- 개발자 취업
- 코딩테스트준비
- 프로그래머스
- 혁펜하임
- 항해99
- 큐
- 백준 2309
- BOJ
- 해시
- 활성화 함수
- 백준
- BFS
- dfs
- easy 딥러닝
- Python
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 (0) | 2024.06.01 |
[99클럽] 11일차 TIL (0) | 2024.05.31 |
[99클럽] 10일차 TIL (0) | 2024.05.30 |