Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Check if the Rectangle Corner Is Reachable

XPChallenge Points: 30
levelLevel: Hard

You are given two integers xCorner and yCorner representing the coordinates of the top-right corner of an axis-aligned rectangle whose bottom-left corner is at (0, 0).

You are also given an array circles, where each element circles[i] = [xi, yi, ri] represents a circle centered at (xi, yi) with radius ri.

Your task is to determine whether it is possible to travel from (0, 0) to (xCorner, yCorner) entirely inside the rectangle, without touching or entering any circle.
The path must only touch the rectangle at the starting and ending points.

Return true if such a path exists; otherwise, return false.

Example 1:

Input: xCorner = 6, yCorner = 4, circles = [[1,3,1],[4,2,1]]

Output: true

Explanation:

Even though there are two circles, there is still free space to create a curved path around them.

Example 2:

Input: xCorner = 2, yCorner = 6, circles = [[1,3,2]]

Output: false

Explanation:

The circle reaches both left and right sides of the rectangle, blocking movement.

Example 3:

Input: xCorner = 5, yCorner = 5, circles = [[3,3,1]]

Output: true

Explanation:

The circle is far from the diagonal area, so a path exists avoiding the circle.

Example 4:

Input: xCorner = 4, yCorner = 4, circles = [[2,2,3]]

Output: false

Explanation:

The circle fully blocks all possible paths from one corner to the other.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result