bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 780. Reaching Points

780. Reaching Points

Leetcode Solutions

Approach #: Work Backwards (Modulo Variant)

  1. While tx and ty are both greater than sx and sy respectively: a. If tx > ty, set tx to tx % ty. b. Else, set ty to ty % tx.
  2. If tx equals sx and ty is greater than sy and the difference ty - sy is divisible by sx, return true.
  3. If ty equals sy and tx is greater than sx and the difference tx - sx is divisible by sy, return true.
  4. If both tx equals sx and ty equals sy, return true.
  5. Otherwise, return false.
UML Thumbnail

Approach #: Exhaustive Search

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...