1036. Escape a Large Maze Hard
1/**
2 * [1036] Escape a Large Maze
3 *
4 * There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y).
5 * We start at the source = [sx, sy] square and want to reach the target = [tx, ty] square. There is also an array of blocked squares, where each blocked[i] = [xi, yi] represents a blocked square with coordinates (xi, yi).
6 * Each move, we can walk one square north, east, south, or west if the square is not in the array of blocked squares. We are also not allowed to walk outside of the grid.
7 * Return true if and only if it is possible to reach the target square from the source square through a sequence of valid moves.
8 *
9 * Example 1:
10 *
11 * Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
12 * Output: false
13 * Explanation: The target square is inaccessible starting from the source square because we cannot move.
14 * We cannot move north or east because those squares are blocked.
15 * We cannot move south or west because we cannot go outside of the grid.
16 *
17 * Example 2:
18 *
19 * Input: blocked = [], source = [0,0], target = [999999,999999]
20 * Output: true
21 * Explanation: Because there are no blocked cells, it is possible to reach the target square.
22 *
23 *
24 * Constraints:
25 *
26 * 0 <= blocked.length <= 200
27 * blocked[i].length == 2
28 * 0 <= xi, yi < 10^6
29 * source.length == target.length == 2
30 * 0 <= sx, sy, tx, ty < 10^6
31 * source != target
32 * It is guaranteed that source and target are not blocked.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/escape-a-large-maze/
38// discuss: https://leetcode.com/problems/escape-a-large-maze/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn is_escape_possible(blocked: Vec<Vec<i32>>, source: Vec<i32>, target: Vec<i32>) -> bool {
44 false
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_1036() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.