check right
Sat May 20 2023 14:57:52 GMT+0000 (Coordinated Universal Time)
Saved by
@gokulz
/**
* Function Name: checkRight
* @param board char[][]
* @return count (int)
* Inside the function
* 1.using single loop to check the left diagnol are same X/O
*
*/
public static int checkRight(char[][] board){
int count=0;
for(int i=0; i<board.length; i++){
if(board[i][2-i]=='X'){
count++;
}
else if(board[i][2-i]=='O'){
count--;
}
}
if(count==3|| count == -3){
return count;
}
else{
count =0;
}
return count;
}
content_copyCOPY
Comments