File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 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 {
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 ;
You can’t perform that action at this time.
0 commit comments