PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

Determine whether a target point with positive integer coordinates can be reached from a starting point using two coordinate-addition moves. Account for values as large as 10^18, targets equal to the start, impossible coordinate relationships, and exact reachability.

  • hard
  • NVIDIA
  • Coding & Algorithms
  • Software Engineer

Determine Whether One Point Can Reach Another

Company: NVIDIA

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

# Determine Whether One Point Can Reach Another You start at a point `(sx, sy)` with positive integer coordinates. From `(x, y)`, one move may transform the point into either: - `(x + y, y)`, or - `(x, x + y)`. Given positive integers `sx`, `sy`, `tx`, and `ty`, return whether the target `(tx, ty)` is reachable from the start. Implement: ```python def solve(sx: int, sy: int, tx: int, ty: int) -> bool: ... ``` ## Constraints - `1 <= sx, sy, tx, ty <= 10^18` ## Examples ```text (1, 1) -> (3, 5) = True (1, 1) -> (2, 2) = False (3, 7) -> (3, 7) = True ```

Quick Answer: Determine whether a target point with positive integer coordinates can be reached from a starting point using two coordinate-addition moves. Account for values as large as 10^18, targets equal to the start, impossible coordinate relationships, and exact reachability.

Implement solve(sx, sy, tx, ty). Coordinates are positive integers supplied as decimal strings so every language preserves values up to 10^18 exactly. One move changes (x, y) to either (x + y, y) or (x, x + y). Return whether the target is reachable from the start.

Constraints

  • sx, sy, tx, and ty are decimal strings for values from 1 through 10^18.
  • All moves use exact positive-integer arithmetic.

Examples

Input: ('1', '1', '3', '5')

Expected Output: True

Explanation: Checks equality, repeated moves, unreachable gcd states, and exact large coordinates.

Input: ('1', '1', '2', '2')

Expected Output: False

Explanation: Checks equality, repeated moves, unreachable gcd states, and exact large coordinates.

Hints

  1. Work backward because the larger target coordinate identifies the last move.
  2. Replace repeated subtraction with a remainder, while handling a coordinate already equal to its start value.
Last updated: Jul 18, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Count Substrings with No Repeated Characters - NVIDIA (hard)
  • Compute the Final Robot Score - NVIDIA (easy)
  • Merge Overlapping Time Intervals - NVIDIA (medium)
  • Return all file paths via DFS - NVIDIA (easy)