mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part2
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<p>Design an algorithm to figure out if someone has won a game of tic-tac-toe. Input is a string array of size N x N, including characters " ", "X" and "O", where " " represents a empty grid.</p>
|
||||
|
||||
<p>The rules of tic-tac-toe are as follows:</p>
|
||||
|
||||
<ul>
|
||||
<li>Players place characters into an empty grid(" ") in turn.</li>
|
||||
<li>The first player always place character "O", and the second one place "X".</li>
|
||||
<li>Players are only allowed to place characters in empty grid. Replacing a character is not allowed.</li>
|
||||
<li>If there is any row, column or diagonal filled with N same characters, the game ends. The player who place the last charater wins.</li>
|
||||
<li>When there is no empty grid, the game ends.</li>
|
||||
<li>If the game ends, players cannot place any character further.</li>
|
||||
</ul>
|
||||
|
||||
<p>If there is any winner, return the character that the winner used. If there's a draw, return "Draw". If the game doesn't end and there is no winner, return "Pending".</p>
|
||||
|
||||
<p><strong>Example 1: </strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input: </strong> board = ["O X"," XO","X O"]
|
||||
<strong>Output: </strong> "X"
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2: </strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input: </strong> board = ["OOX","XXO","OXO"]
|
||||
<strong>Output: </strong> "Draw"
|
||||
<strong>Explanation: </strong> no player wins and no empty grid left
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3: </strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input: </strong> board = ["OOX","XXO","OX "]
|
||||
<strong>Output: </strong> "Pending"
|
||||
<strong>Explanation: </strong> no player wins but there is still a empty grid
|
||||
</pre>
|
||||
|
||||
<p><strong>Note: </strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= board.length == board[i].length <= 100</code></li>
|
||||
<li>Input follows the rules.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user