• + 1 comment

    Python: O(1) solution

    def kangaroo(x1, v1, x2, v2):
        # Write your code here
        
        if v1 <= v2:
            return "NO"
            
        if v1 % v2 == 0 and (x2 % x1 == 0):
            return "YES"
            
        n_steps = (x2 - x1) / (v1 - v2)
        
        if n_steps % 1 == 0:
            return "YES"
        
        return "NO"