ํ์ด BFS๋ก ํ์๋๋ฐ, ๋ฐฐ์ด์ด reference๋ก ์ ๋ฌ๋์ด ์ ๋จน์๋ค. Code from collections import deque def solution(tickets): answers = [] q = deque() used = [False for _ in tickets ] answer = ["ICN"] q.append(["ICN", used, answer]) while q: start, used, answer = q.pop() if all(used): answers.append(answer) for i, (s, e) in enumerate(tickets): if s == start and used[i] == False: _used = used[:] _answer = answer[:] _used[i] = True _answer.append(e) q.append([e, _used, _answer]) # print(answers.sort()) answers.sort() return answers[0] Reference ์ฌํ ๊ฒฝ๋ก