3001. Minimum Moves to Capture The Queen Medium
1/**
2 * [3001] Minimum Moves to Capture The Queen
3 *
4 * There is a 1-indexed 8 x 8 chessboard containing 3 pieces.
5 * You are given 6 integers a, b, c, d, e, and f where:
6 *
7 * (a, b) denotes the position of the white rook.
8 * (c, d) denotes the position of the white bishop.
9 * (e, f) denotes the position of the black queen.
10 *
11 * Given that you can only move the white pieces, return the minimum number of moves required to capture the black queen.
12 * Note that:
13 *
14 * Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.
15 * Bishops can move any number of squares diagonally, but cannot jump over other pieces.
16 * A rook or a bishop can capture the queen if it is located in a square that they can move to.
17 * The queen does not move.
18 *
19 *
20 * <strong class="example">Example 1:
21 * <img alt="" src="https://assets.leetcode.com/uploads/2023/12/21/ex1.png" style="width: 600px; height: 600px; padding: 10px; background: #fff; border-radius: .5rem;" />
22 * Input: a = 1, b = 1, c = 8, d = 8, e = 2, f = 3
23 * Output: 2
24 * Explanation: We can capture the black queen in two moves by moving the white rook to (1, 3) then to (2, 3).
25 * It is impossible to capture the black queen in less than two moves since it is not being attacked by any of the pieces at the beginning.
26 *
27 * <strong class="example">Example 2:
28 * <img alt="" src="https://assets.leetcode.com/uploads/2023/12/21/ex2.png" style="width: 600px; height: 600px;padding: 10px; background: #fff; border-radius: .5rem;" />
29 * Input: a = 5, b = 3, c = 3, d = 4, e = 5, f = 2
30 * Output: 1
31 * Explanation: We can capture the black queen in a single move by doing one of the following:
32 * - Move the white rook to (5, 2).
33 * - Move the white bishop to (5, 2).
34 *
35 *
36 * Constraints:
37 *
38 * 1 <= a, b, c, d, e, f <= 8
39 * No two pieces are on the same square.
40 *
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/minimum-moves-to-capture-the-queen/
45// discuss: https://leetcode.com/problems/minimum-moves-to-capture-the-queen/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50 pub fn min_moves_to_capture_the_queen(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) -> i32 {
51 0
52 }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn test_3001() {
63 }
64}
65
Back
© 2025 bowen.ge All Rights Reserved.