Reaching Points


  • 0
    L

    A bot takes a pair of integers coordinates (x,y). Though this bot can move any number of times, it can only make the following two types of moves:

    1. From location (x,y) to location (x+y,y).
    2. From location (x,y) to location (x,x+y).

    For example, if the bot starts at (1,4), it can make the following sequence of moves: (1,4) -> (5,4) -> (5,9) -> (5,14).

    Complete the canReach function. It has four integer parameters: x1,y1,x2 and y2. It must return the string YES if it is possible for the bot to start at point (x1,y1) and reach point (x2,y2); otherwise, it must return the string NO.

    Constraints:
    1 <= x1, y1, x2, y2 <= 1000


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.