프로그래머스 방문 길이 - java


프로그래머스 방문 길이 - java

Set을 써보자. import java.util.*; class Solution { boolean DEBUG = false; void log(String s) { if (DEBUG) { System.out.println(s); } } public int solution(String dirs) { int answer = 0; // Set을 써보자 HashSet<String> newRoutes = new HashSet<>(); int x = 0, y = 0; for (int i = 0 ; i < dirs.length() ; i++) { String route = getRoute(dirs.charAt(i), x, y); if (!route.equals("stop")){ newRoutes.add(route); int[] position = getPosition(dirs.charAt(i), x, y); x = position[0]; y = position[1]; log(route); log(...



원문링크 : 프로그래머스 방문 길이 - java