_0794

package
v0.0.0-...-a49be92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 1 Imported by: 0

README

有效的井字游戏

给你一个字符串数组 board 表示井字游戏的棋盘。当且仅当在井字游戏过程中,棋盘有可能达到 board 所显示的状态时,才返回 true

井字游戏的棋盘是一个 3 x 3 数组,由字符 ' ''X''O' 组成。字符 ' ' 代表一个空位。

以下是井字游戏的规则:

  • 玩家轮流将字符放入空位(' ')中。
  • 玩家 1 总是放字符 'X' ,而玩家 2 总是放字符 'O'
  • 'X''O' 只允许放置在空位中,不允许对已放有字符的位置进行填充。
  • 当有 3 个相同(且非空)的字符填充任何行、列或对角线时,游戏结束。
  • 当所有位置非空时,也算为游戏结束。
  • 如果游戏结束,玩家不允许再放置字符。

示例 1:

``` 输入:board = ["O "," "," "] 输出:false 解释:玩家 1 总是放字符 "X" 。


**示例 2:**

![](https://assets.leetcode.com/uploads/2021/05/15/tictactoe2-grid.jpg)```
输入:board = ["XOX"," X ","   "]
输出:false
解释:玩家应该轮流放字符。

示例 3:

``` 输入:board = ["XXX"," ","OOO"] 输出:false


**Example 4:**

![](https://assets.leetcode.com/uploads/2021/05/15/tictactoe4-grid.jpg)```
输入:board = ["XOX","O O","XOX"]
输出:true

提示:

  • board.length == 3
  • board[i].length == 3
  • board[i][j]'X''O'' '

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL