JAVA_LeetCode 1275_Find Winner on a Tic Tac Toe Game


JAVA_LeetCode 1275_Find Winner on a Tic Tac Toe Game

JAVA_LeetCode 1275_Find Winner on a Tic Tac Toe Game 풀이 class Solution { public String tictactoe(int[][] moves) { // moves의 길이, row와 col값, 왼쪽 대각선, 오른쪽 대각선 미리 선언한다. int len = moves.length; int[][] row = new int[2][3], col = new int[2][3]; int[] flag1 = new int[2], flag2 = new int[2]; for (int i = 0; i < len; ++i) { int num1 = moves[i][0], num2 = moves[i][1]; int j = i % 2; // 각 row또는 col의 수가 총 3인경우 또는 값이 같거나(왼쪽 대각선) 둘이 더한 값이 2일때(오른쪽 대각선) 해당 플래그 값이 3인경우 if (++row[j][num1] == 3 || ++col[j][num2] ==...


#JAVA #JAVA_FindWinneronaTicTacToeGame #JAVA_LeetCode1275 #JAVA_LeetCode1275_FindWinneronaTicTacToeGame #LeetCode1275_FindWinneronaTicTacToeGame

원문링크 : JAVA_LeetCode 1275_Find Winner on a Tic Tac Toe Game