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