leetcode在力扣 App 中打开
调试中...
调试中...
题目描述
题目描述
题解
题解
提交记录
提交记录
代码
代码
测试用例
测试用例
测试结果
测试结果
简单
相关标签
相关企业
提示

给你两个字符串 coordinate1coordinate2,代表 8 x 8 国际象棋棋盘上的两个方格的坐标。

以下是棋盘的参考图。

如果这两个方格颜色相同,返回 true,否则返回 false

坐标总是表示有效的棋盘方格。坐标的格式总是先字母(表示列),再数字(表示行)。

 

示例 1:

输入: coordinate1 = "a1", coordinate2 = "c3"

输出: true

解释:

两个方格均为黑色。

示例 2:

输入: coordinate1 = "a1", coordinate2 = "h3"

输出: false

解释:

方格 "a1" 是黑色,而 "h3" 是白色。

 

提示:

  • coordinate1.length == coordinate2.length == 2
  • 'a' <= coordinate1[0], coordinate2[0] <= 'h'
  • '1' <= coordinate1[1], coordinate2[1] <= '8'
通过次数
25.9K
提交次数
32.6K
通过率
79.4%

相关标签

相关企业

提示 1
The color of the chessboard is black the sum of row coordinates and column coordinates is even. Otherwise, it's white.


评论 (0)

贡献者
© 2025 领扣网络(上海)有限公司
0 人在线
行 1,列 1
运行和提交代码需要登录
coordinate1 =
"a1"
coordinate2 =
"c3"
Source