Skip to content

Practice Reaching Points

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

Hard#780
LeetCode Problem

Reaching Points

Problem Statement

Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise. The allowed operation on some point (x, y) is to convert it to either (x, x + y) or (x + y, y).

Source: Reaching Points on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
sx = 1, sy = 1, tx = 3, ty = 5
Output
true

# Example 2

Input
sx = 1, sy = 1, tx = 2, ty = 2
Output
false

# Example 3

Input
sx = 1, sy = 1, tx = 1, ty = 1
Output
true

Constraints

1 <= sx, sy, tx, ty <= 10^9

Related LeetCode Problems

Practice more problems similar to Reaching Points.

Review your practice with PhantomCodeAI

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