Skip to content

Commit e331cad

Browse files
committedJun 10, 2024·
update 348
1 parent 14e9ee9 commit e331cad

File tree

1 file changed

+12
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+12
-2
lines changed
 

‎src/main/java/com/fishercoder/solutions/_348.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,28 @@ public static class Solution1 {
88
* Key: in order to win a TicTacToe, you must have the entire row or column, thus, we don't need
99
* to keep track of the entire n^2 board. We only need to keep a count for each row and column.
1010
* If at any time, a row or column matches the size of the board, then that player has won.
11+
* <p>
12+
* We use 1 to denote a move for Player 1, -1 for Player 2.
1113
*/
1214
public static class TicTacToe {
1315

1416
private int diagonal;
1517
/**
16-
* This is diagonal: |X| | | | |X| | | | |X| So, its condition is always like this: if (row ==
18+
* This is diagonal:
19+
* |X| | |
20+
* | |X| |
21+
* | | |X|
22+
* So, its condition is always like this: if (row ==
1723
* col)
1824
*/
1925

2026
private int antidiagonal;
2127
/**
22-
* This is antidiagonal: | | |X| | |X| | |X| | | So, its condition is always like this: if
28+
* This is antidiagonal:
29+
* | | |X|
30+
* | |X| |
31+
* |X| | |
32+
* So, its condition is always like this: if
2333
* (col == size - row - 1)
2434
*/
2535
private int[] rows;

0 commit comments

Comments
 (0)
Please sign in to comment.