• + 0 comments

    This is my code in js:

    function kangaroo(x1, v1, x2, v2) {
        // Write your code here
        // constraint given x2 >x1
        let dist = x2-x1;
            
        while(dist>0){
        x1 += v1;
        x2 += v2;
        
        if(x1===x2) return 'YES';   
        else if ((x2-x1)>=dist)return 'NO';
        else dist = x2 - x1;
        }   
        return 'NO';
    }