[Programmers] 방의 개수
시작하기 전에프로그래머스 알고리즘 고득점 Kit에서 그래프 단원의 세 번째 문제입니다.I. DescriptionII. Codedef solution(arrows): directions = [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)] visited_nodes = set([(0, 0)]) visited_edges = set() room_count = 0 # 방의 개수 x, y = 0, 0 for arrow in arrows: dx, dy = directions[arrow] nx, ny = x + dx, y + dy if ..
2025. 8. 17.