class TicTacToe { int n; int[] rows; int[] cols; int diag=0; int antiDiag = 0; public TicTacToe(int n) { this.n = n; rows = new int[n]; cols = new int[n]; } public int move(int row, int col, int player) { int add = 1; if(player!=1) add = -1; rows[row]+=add; cols[col]+=add; if(row==col) diag+=add; if(row == n-col-1) antiDiag+=add; if(Math.abs(rows[row])==n||Math.abs(cols[col])==n||Math.abs(diag)==n||Math.abs(antiDiag)==n) return player; return 0; } } /** * Your TicTacToe object will be instantiated and called as such: * TicTacToe obj = new TicTacToe(n); * int param_1 = obj.move(row,col,player); */