• + 1 comment

    looping it till 10000 is not a solution as for large dataset it can take more than that

    if(v1>v2 && x1>x2 )
                {
                System.out.print("NO");
            }
            else if(v2>v1 && x2>x1)
                {
                System.out.print("NO");
            }
            else
                {
                   if((v1!=v2) && ((x2-x1)%(v1-v2))==0)
                       System.out.println("YES");
                    else
                    System.out.println("NO");
                }