3235. Check if the Rectangle Corner Is Reachable Hard
1/**
2 * [3235] Check if the Rectangle Corner Is Reachable
3 *
4 * You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [xi, yi, ri] denotes a circle with center at (xi, yi) and radius ri.
5 * There is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You need to check whether there is a path from the bottom left corner to the top right corner such that the entire path lies inside the rectangle, does not touch or lie inside any circle, and touches the rectangle only at the two corners.
6 * Return true if such a path exists, and false otherwise.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">xCorner = 3, yCorner = 4, circles = [[2,1,1]]</span>
11 * Output: <span class="example-io">true</span>
12 * Explanation:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2024/05/18/example2circle1.png" style="width: 346px; height: 264px;" />
14 * The black curve shows a possible path between (0, 0) and (3, 4).
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">xCorner = 3, yCorner = 3, circles = [[1,1,2]]</span>
19 * Output: <span class="example-io">false</span>
20 * Explanation:
21 * <img alt="" src="https://assets.leetcode.com/uploads/2024/05/18/example1circle.png" style="width: 346px; height: 264px;" />
22 * No path exists from (0, 0) to (3, 3).
23 * </div>
24 * <strong class="example">Example 3:
25 * <div class="example-block">
26 * Input: <span class="example-io">xCorner = 3, yCorner = 3, circles = [[2,1,1],[1,2,1]]</span>
27 * Output: <span class="example-io">false</span>
28 * Explanation:
29 * <img alt="" src="https://assets.leetcode.com/uploads/2024/05/18/example0circle.png" style="width: 346px; height: 264px;" />
30 * No path exists from (0, 0) to (3, 3).
31 * </div>
32 * <strong class="example">Example 4:
33 * <div class="example-block">
34 * Input: <span class="example-io">xCorner = 4, yCorner = 4, circles = [[5,5,1]]</span>
35 * Output: <span class="example-io">true</span>
36 * Explanation:
37 * <img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/rectangles.png" style="width: 346px; height: 264px;" />
38 * </div>
39 *
40 * Constraints:
41 *
42 * 3 <= xCorner, yCorner <= 10^9
43 * 1 <= circles.length <= 1000
44 * circles[i].length == 3
45 * 1 <= xi, yi, ri <= 10^9
46 *
47 */
48pub struct Solution {}
49
50// problem: https://leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/
51// discuss: https://leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/discuss/?currentPage=1&orderBy=most_votes&query=
52
53// submission codes start here
54
55impl Solution {
56 pub fn can_reach_corner(x_corner: i32, y_corner: i32, circles: Vec<Vec<i32>>) -> bool {
57 false
58 }
59}
60
61// submission codes end
62
63#[cfg(test)]
64mod tests {
65 use super::*;
66
67 #[test]
68 fn test_3235() {
69 }
70}
71
Back
© 2025 bowen.ge All Rights Reserved.