목록BFS (2)
IT보안관의 공부 클라우드
코딩테스트 연습 - 게임 맵 최단거리 | 프로그래머스 (programmers.co.kr) 코딩테스트 연습 - 게임 맵 최단거리 [[1,0,1,1,1],[1,0,1,0,1],[1,0,1,1,1],[1,1,1,0,1],[0,0,0,0,1]] 11 [[1,0,1,1,1],[1,0,1,0,1],[1,0,1,1,1],[1,1,1,0,0],[0,0,0,0,1]] -1 programmers.co.kr from collections import deque # 동 서 남 북 dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] def bfs(graph): n = len(graph) m = len(graph[0]) # visit = [[0 for i in range(m)]for i in range(n)] q..
https://www.youtube.com/watch?v=7C9RgOcvkvo&list=PLRx0vPvlEmdAghTr5mXQxGpHjWqSz0dgC&index=3 from collections import deque def bfs(x,y,graph): q = deque([[x,y,graph[x][y]]]) print(q) prev=0 while 1: a,b,c=q.popleft() # print(q, a, b) if a == n - 1 and b == m - 1: graph[a][b] +=c return graph if a = n or b>= m: continue print(q, a, b) for i in graph: print(i) if graph[a][b] == 0..