• + 1 comment

    I known that there was a matemathic way to solve it it a simple operation but I didn't know how.

    So, according to this, if x2 is strictly greater than x1, I realized that the distance between the kangaroos decrease for each jump, thus I wrote the following:

            int diference = 0;
            do {
                x1+=v1;
                x2+=v2;
                diference = x1 - x2;
                if (diference == 0) {
                    return "YES";    
                } else if (diference > 0) {
                    return "NO";
                }
            } while (true);