File tree 1 file changed +12
-2
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,28 @@ public static class Solution1 {
8
8
* Key: in order to win a TicTacToe, you must have the entire row or column, thus, we don't need
9
9
* to keep track of the entire n^2 board. We only need to keep a count for each row and column.
10
10
* 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.
11
13
*/
12
14
public static class TicTacToe {
13
15
14
16
private int diagonal ;
15
17
/**
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 ==
17
23
* col)
18
24
*/
19
25
20
26
private int antidiagonal ;
21
27
/**
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
23
33
* (col == size - row - 1)
24
34
*/
25
35
private int [] rows ;
You can’t perform that action at this time.
0 commit comments