Tap here to switch tabs
Problem
Submissions

Problem: Check if Point Is Reachable

med
30 min
Try to solve the Check if Point Is Reachable problem.

Statement

You are standing at point (1,1)(1, 1) on an infinite two dimensional grid. From any point (x,y)(x, y), you can move to one of the following coordinates:

  • (x,y−x)(x, y - x)

  • (x−y,y)(x - y, y)

  • (2⋅x,y)(2 \cdot x, y)

  • (x,2⋅y)(x, 2 \cdot y)

Given two integers targetX and targetY, return true if you can reach the point (targetX, targetY) starting from (1,1)(1, 1), or false otherwise.

Constraints:

  • 1≤1 \leq targetX, targetY ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Point Is Reachable

med
30 min
Try to solve the Check if Point Is Reachable problem.

Statement

You are standing at point (1,1)(1, 1) on an infinite two dimensional grid. From any point (x,y)(x, y), you can move to one of the following coordinates:

  • (x,y−x)(x, y - x)

  • (x−y,y)(x - y, y)

  • (2⋅x,y)(2 \cdot x, y)

  • (x,2⋅y)(x, 2 \cdot y)

Given two integers targetX and targetY, return true if you can reach the point (targetX, targetY) starting from (1,1)(1, 1), or false otherwise.

Constraints:

  • 1≤1 \leq targetX, targetY ≤109\leq 10^9