프로그래머스 lv2 탐색기본문제에 줘터지는중

https://programmers.co.kr/learn/courses/30/lessons/43165


백준 dfs bfs으로 연습하는게 더 완만할까?