"""Leetcode 780. Reaching Points
Hard

URL: https://leetcode.com/problems/reaching-points/

A move consists of taking a point (x, y) and transforming it to either
(x, x+y) or (x+y, y).

Given a starting point (sx, sy) and a target point (tx, ty),
return True if and only if a sequence of moves exists to transform the point
(sx, sy) to (tx, ty). Otherwise, return False.

Examples:
Input: sx = 1, sy = 1, tx = 3, ty = 5
Output: True
Explanation:
One series of moves that transforms the starting point to the target is:
(1, 1) -> (1, 2)
(1, 2) -> (3, 2)
(3, 2) -> (3, 5)

Input: sx = 1, sy = 1, tx = 2, ty = 2
Output: False

Input: sx = 1, sy = 1, tx = 1, ty = 1
Output: True

Note:
sx, sy, tx, ty will all be integers in the range [1, 10^9].
"""

class Solution(object):
    def reachingPoints(self, sx, sy, tx, ty):
        """
        :type sx: int
        :type sy: int
        :type tx: int
        :type ty: int
        :rtype: bool
        """
        pass


def main():
    pass


if __name__ == '__main__':
    main()

@@ -754,16 +754,28 @@
 Solution
+TopDownRecur
 (object)
@@ -947,55 +947,819 @@
 ool%0A
-        %22%22%22%0A        pass%0A%0A%0Adef main():%0A    pass
+%0A        Note: Time limit exceeded.%0A%0A        Time complexity: O(2%5En), where n = max(tx, ty).%0A        Space complexity: O(n).%0A        %22%22%22%0A        # Base case: when start meets target.%0A        if sx == tx and sy == ty:%0A            return True%0A%0A        # Out of boundary cases.%0A        if sx %3E tx or sy %3E ty:%0A            return False%0A%0A        return (self.reachingPoints(sx + sy, sy, tx, ty) or%0A                self.reachingPoints(sx, sx + sy, tx, ty))%0A%0A%0Adef main():%0A    # Output: True%0A    sx, sy, tx, ty = 1, 1, 3, 5%0A    print SolutionTopDownRecur().reachingPoints(sx, sy, tx, ty)%0A%0A    # Output: False%0A    sx, sy, tx, ty = 1, 1, 2, 2%0A    print SolutionTopDownRecur().reachingPoints(sx, sy, tx, ty)%0A%0A    # Output: True%0A    sx, sy, tx, ty = 1, 1, 1, 1%0A    print SolutionTopDownRecur().reachingPoints(sx, sy, tx, ty)
 %0A%0A%0Ai

Complete naive top down recur sol w/ time/space complexity