(Java) 프로그래머스 - 공원 산책
·
코딩 테스트
추가된 1단계 문제중 가장 정답률이 낮은 문제였다. 전형적인 그래프 탐색 문제였는데, 한칸씩 이동하며 조건을 검사해야 했지만 한번에 n칸씩 이동한다는걸 뒤늦게 깨닫고 수정하느라 풀이 시간이 많이 늘어났다. 최종 코드 import java.util.*; class Solution { static int startX; static int startY; public int[] solution(String[] park, String[] routes) { int[] answer = new int[2]; // 동서남북 이동할 좌표 map에 삽입 Map map = new HashMap(); map.put("N", new int[]{-1, 0}); map.put("E", new int[]{0, 1}); map.put(..