|
6 | 6 |
|
7 | 7 | <!-- 这里写题目描述 -->
|
8 | 8 |
|
9 |
| -<p>在一个 <strong>8x8</strong> 的棋盘上,放置着若干「黑皇后」和一个「白国王」。</p> |
| 9 | +<p>在一个 <strong>下标从 0 开始</strong> 的 <code>8 x 8</code> 棋盘上,可能有多个黑皇后和一个白国王。</p> |
10 | 10 |
|
11 |
| -<p>给定一个由整数坐标组成的数组 <code>queens</code> ,表示黑皇后的位置;以及一对坐标 <code>king</code> ,表示白国王的位置,返回所有可以攻击国王的皇后的坐标(任意顺序)。</p> |
| 11 | +<p>给你一个二维整数数组 <code>queens</code>,其中 <code>queens[i] = [xQueeni, yQueeni]</code> 表示第 <code>i</code> 个黑皇后在棋盘上的位置。还给你一个长度为 <code>2</code> 的整数数组 <code>king</code>,其中 <code>king = [xKing, yKing]</code> 表示白国王的位置。</p> |
| 12 | + |
| 13 | +<p>返回 <em>能够直接攻击国王的黑皇后的坐标</em>。你可以以 <strong>任何顺序</strong> 返回答案。</p> |
12 | 14 |
|
13 | 15 | <p> </p>
|
14 | 16 |
|
15 | 17 | <p><strong>示例 1:</strong></p>
|
16 | 18 |
|
17 |
| -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1222.Queens%20That%20Can%20Attack%20the%20King/images/untitled-diagram.jpg" /></p> |
| 19 | +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1222.Queens%20That%20Can%20Attack%20the%20King/images/1703052515-HqjAJq-chess1.jpg" style="width: 400px; height: 400px;" /></p> |
18 | 20 |
|
19 | 21 | <pre>
|
20 | 22 | <strong>输入:</strong>queens = [[0,1],[1,0],[4,0],[0,4],[3,3],[2,4]], king = [0,0]
|
21 | 23 | <strong>输出:</strong>[[0,1],[1,0],[3,3]]
|
22 |
| -<strong>解释:</strong> |
23 |
| -[0,1] 的皇后可以攻击到国王,因为他们在同一行上。 |
24 |
| -[1,0] 的皇后可以攻击到国王,因为他们在同一列上。 |
25 |
| -[3,3] 的皇后可以攻击到国王,因为他们在同一条对角线上。 |
26 |
| -[0,4] 的皇后无法攻击到国王,因为她被位于 [0,1] 的皇后挡住了。 |
27 |
| -[4,0] 的皇后无法攻击到国王,因为她被位于 [1,0] 的皇后挡住了。 |
28 |
| -[2,4] 的皇后无法攻击到国王,因为她和国王不在同一行/列/对角线上。 |
| 24 | +<strong>解释:</strong>上面的图示显示了三个可以直接攻击国王的皇后和三个不能攻击国王的皇后(用红色虚线标记)。 |
29 | 25 | </pre>
|
30 | 26 |
|
31 | 27 | <p><strong>示例 2:</strong></p>
|
32 | 28 |
|
33 |
| -<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1222.Queens%20That%20Can%20Attack%20the%20King/images/untitled-diagram-1.jpg" /></strong></p> |
| 29 | +<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1222.Queens%20That%20Can%20Attack%20the%20King/images/1703052660-bPPflt-chess2.jpg" style="width: 400px; height: 400px;" /></strong></p> |
34 | 30 |
|
35 | 31 | <pre>
|
36 | 32 | <strong>输入:</strong>queens = [[0,0],[1,1],[2,2],[3,4],[3,5],[4,4],[4,5]], king = [3,3]
|
37 | 33 | <strong>输出:</strong>[[2,2],[3,4],[4,4]]
|
38 |
| -</pre> |
39 |
| - |
40 |
| -<p><strong>示例 3:</strong></p> |
41 |
| - |
42 |
| -<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1222.Queens%20That%20Can%20Attack%20the%20King/images/untitled-diagram-2.jpg" /></strong></p> |
43 |
| - |
44 |
| -<pre> |
45 |
| -<strong>输入:</strong>queens = [[5,6],[7,7],[2,1],[0,7],[1,6],[5,1],[3,7],[0,3],[4,0],[1,2],[6,3],[5,0],[0,4],[2,2],[1,1],[6,4],[5,4],[0,0],[2,6],[4,5],[5,2],[1,4],[7,5],[2,3],[0,5],[4,2],[1,0],[2,7],[0,1],[4,6],[6,1],[0,6],[4,3],[1,7]], king = [3,4] |
46 |
| -<strong>输出:</strong>[[2,3],[1,4],[1,6],[3,7],[4,3],[5,4],[4,5]] |
47 |
| -</pre> |
| 34 | +<strong>解释:</strong>上面的图示显示了三个能够直接攻击国王的黑皇后和三个不能攻击国王的黑皇后(用红色虚线标记)。</pre> |
48 | 35 |
|
49 | 36 | <p> </p>
|
50 | 37 |
|
51 | 38 | <p><strong>提示:</strong></p>
|
52 | 39 |
|
53 | 40 | <ul>
|
54 |
| - <li><code>1 <= queens.length <= 63</code></li> |
55 |
| - <li><code>queens[i].length == 2</code></li> |
56 |
| - <li><code>0 <= queens[i][j] < 8</code></li> |
57 |
| - <li><code>king.length == 2</code></li> |
58 |
| - <li><code>0 <= king[0], king[1] < 8</code></li> |
59 |
| - <li>一个棋盘格上最多只能放置一枚棋子。</li> |
| 41 | + <li><meta charset="UTF-8" /><code>1 <= queens.length < 64</code></li> |
| 42 | + <li><code>queens[i].length == king.length == 2</code></li> |
| 43 | + <li><code>0 <= xQueen<sub>i</sub>, yQueen<sub>i</sub>, xKing, yKing < 8</code></li> |
| 44 | + <li>所有给定的位置都是 <strong>唯一</strong> 的。</li> |
60 | 45 | </ul>
|
61 | 46 |
|
62 | 47 | ## 解法
|
|
0 commit comments