Reaching Points
Updated
Problem statement
Start at the positive coordinate (sx, sy). In one move, replace it with either (sx + sy, sy) or (sx, sx + sy).
Return whether some sequence of moves reaches (tx, ty).
Function
reachingPoints(sx: int, sy: int, tx: int, ty: int) → booleanExamples
Example 1
sx = 1sy = 1tx = 3ty = 5return = true(1,1) can move to (1,2), then (3,2), then (3,5).
Example 2
sx = 1sy = 1tx = 2ty = 2return = falseNeither legal move can produce (2,2).
Constraints
1 <= sx, sy, tx, ty <= 10^9
More Goldman Sachs Online Assessment questions
- Design Hash MapOA · PHONE SCREEN · Seen Nov 2026
- Maximum Ones After K OperationsOA · Seen Nov 2026
- Palindrome CounterOA · Seen Oct 2026
- Longest Palindromic SubsequenceOA · Seen Oct 2026
- Count Redundant File BackupsOA · Seen Oct 2026
- Minimum Distinct Prefix CostOA · Seen Oct 2026
- Merge Overlapping IntervalsOA · Seen Sep 2026
- Data ReorganizationOA · Seen Jul 2026
- Alternating Parity PermutationsOA · Seen Jul 2026
- Threshold AlertsOA · Seen Jul 2026
Similar questions at other companies
- Expected Profit of a Doubling Betting SystemOptiver · OAOptiver interview questions
- Magic Number Range CounterGraviton · OA
- At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
- Delete and Freeze GameRubrik · OARubrik interview questions
- Lock CodeVisa · OAVisa interview questions
- Bootstrap Decision Tree ClassifierPinterest · OAPinterest interview questions
- Maximum Signal Walk in a Server TreeTower Research Capital · OA
- Ordered-Pair Checksum SumBirla Pivot · OA
- Count Pairs with K Divisible Values in the IntervalChubb · OAChubb interview questions
- Predict Taxi Driver ClassesBoston Consulting Group · OABoston Consulting Group interview questions