import java.util.*; class Solution { Set passedWaySet =new HashSet(); String[] targetGrid; public int[] solution(String[] grid) { List ansList=new ArrayList(); targetGrid=grid.clone(); for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length(); j++) { Way down = new Way(i, j, 'D'); Way up = new Way(i, j, 'U'); Way right = new Way(i, j, 'R'); Way left = new Way(i, j, 'L'); //지나간..
class Solution { private static String[] gameBoard; public int solution(String[] board) { //X가 더 많으면 무조건 false //O와 X의 차이가 2이상이면 false //O로 끝낸경우, X는 O갯수보다 하나 작다 //X로 끝낸경우, X는 O의 갯수와 같다. //O,X둘 다 끝낸 경우는 존재하지 않는다. gameBoard=board.clone(); int countX=0, countO=0; for (String s : board) { countO+= s.chars().filter(c -> c == 'O').count(); countX+= s.chars().filter(c -> c == 'X').count(); } if(countX>..
import java.util.ArrayList; import java.util.List; class Solution { public int[] solution(int m, int n, int startX, int startY, int[][] balls) { List ansList=new ArrayList(); for (int[] ball : balls) { int targetX=ball[0]; int targetY=ball[1]; if(targetX==startX){ int widthPow=(targetY-startY)*(targetY-startY); int heightPow1,heightPow2; heightPow1=(2*(m-targetX))*(2*(m-targetX)); heightPow2=(2*..
66.7/100 코드 import java.util.*; import java.util.stream.Collectors; public class Solution { public static int answer=Integer.MAX_VALUE; public int solution(String[] board) { //일단 dfs로 .. ㄱ ㄱ int x = 0,y=0; boolean findFlag=false; for (int j=0;janswer) return; List possiblePoint = getPossiblePoint(point, board); //이동 가능한 점이 없는 경우 return if(possiblePoint.isEmpty()) return; possiblePoint.forEach(pt..