Sort by

recency

|

3933 Discussions

|

  • + 1 comment

    I am struggling to understand why on earth this usecase expects YES: x1 = 0 x2 = 3 v1 = 4 v2 = 2 If the first jump gets x1 at position 4 and x2 at position 5 then in teh second jump x1 surpass x2 and stays ahead from there onwards.

  • + 0 comments

    def kangaroo(x1, v1, x2, v2):

    if v1 > v2 and (x1 - x2) % (v1 - v2) == 0:
        return 'YES'
    return 'NO'
    
  • + 0 comments

    def kangaroo(x1, v1, x2, v2): if v1 > v2 and (x1 - x2) % (v1 - v2) == 0: return 'YES' return 'NO'

  • + 0 comments

    This is my solution in perl

    # Write your code here
    my (`$x1, $`v1, `$x2, $`v2) = @_;    
    if( `$v1 > $`v2 && (`$x2 - $`x1) % (`$v1 - $`v2) == 0)   {
        return "YES";
    }else{
        return "NO";
    }
    
  • + 0 comments

    Here is my c++ solution, you can have the explanation here : https://youtu.be/bRVVCCmXN0Y

    string kangaroo(int x1, int v1, int x2, int v2) {
        if(v1 > v2 && (x2-x1) % (v1-v2) == 0) return "YES";
        return "NO";
    }