Skip to content

Practice Check if Point Is Reachable

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2543
LeetCode Problem

Check if Point Is Reachable

Problem Statement

Start at (1,1) on an infinite grid. From (x,y), one move may go to (x,y-x), (x-y,y), (2x,y), or (x,2y). Return whether some finite sequence of these moves reaches (targetX,targetY).

Source: Check if Point Is Reachable on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
targetX = 6, targetY = 9
Output
false

# Example 2

Input
targetX = 4, targetY = 7
Output
true

Constraints

1 <= targetX, targetY <= 10^9

Related LeetCode Problems

Practice more problems similar to Check if Point Is Reachable.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.