1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/检查棋盘方格颜色是否相同 [check-if-two-chessboard-squares-have-the-same-color].html
2024-09-19 09:27:23 +08:00

46 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你两个字符串 <code>coordinate1</code><code>coordinate2</code>,代表 <code>8 x 8</code> 国际象棋棋盘上的两个方格的坐标。</p>
<p>以下是棋盘的参考图。</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png" style="width: 400px; height: 396px;" /></p>
<p>如果这两个方格颜色相同,返回 <code>true</code>,否则返回 <code>false</code></p>
<p>坐标总是表示有效的棋盘方格。坐标的格式总是先字母(表示列),再数字(表示行)。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "c3"</span></p>
<p><strong>输出:</strong> <span class="example-io">true</span></p>
<p><strong>解释:</strong></p>
<p>两个方格均为黑色。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "h3"</span></p>
<p><strong>输出:</strong> <span class="example-io">false</span></p>
<p><strong>解释:</strong></p>
<p>方格 <code>"a1"</code> 是黑色,而 <code>"h3"</code> 是白色。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>coordinate1.length == coordinate2.length == 2</code></li>
<li><code>'a' &lt;= coordinate1[0], coordinate2[0] &lt;= 'h'</code></li>
<li><code>'1' &lt;= coordinate1[1], coordinate2[1] &lt;= '8'</code></li>
</ul>