숫자 문자열과 영단어 / 프로그래머스
정답 (replace 사용 버전)dictionary.items(): 딕셔너리의 키벨류 값을 동시에 가져옴print(num_dict.items())# dict_items([('zero', '0'), ('one', '1'), ('two', '2'), ..., ('nine', '9')])s.replace(key, value) : key를 value값으로 변경해줌def solution(s): dictionary = {"zero":"0", "one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine":"9"} for key, value in dicti..
2606 바이러스 / DFS,BFS
접근 방법1. 먼저 연결 정보를 입력 받기n = int(input())m = int(input())# 1. 연결 정보에 대해 입력 받기con = []for _ in range(m): a, b = map(int, input().split()) con.append((a, b))# con = [[1, 2], [2, 3], [3, 5] ....] 2. 방문 여부를 확인하는 리스트 생성visited = [False] * (n+1) 3. 연결 정보 -> 그래프로 표현 (양방향 연결)graph = {} for i in range(1, n+1): graph[i] = [] # 결과 : {1: [], 2: [], 3: [], 4: [], 5: []} for a, b in con: ..