mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
44 lines
1.7 KiB
HTML
44 lines
1.7 KiB
HTML
<p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
|
|
|
|
<p>Below is the chessboard for reference.</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>Return <code>true</code> if these two squares have the same color and <code>false</code> otherwise.</p>
|
|
|
|
<p>The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first (indicating its column), and the number second (indicating its row).</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "c3"</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>Both squares are black.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "h3"</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>Square <code>"a1"</code> is black and <code>"h3"</code> is white.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>coordinate1.length == coordinate2.length == 2</code></li>
|
|
<li><code>'a' <= coordinate1[0], coordinate2[0] <= 'h'</code></li>
|
|
<li><code>'1' <= coordinate1[1], coordinate2[1] <= '8'</code></li>
|
|
</ul>
|