code on daily basis with me




–DAY 5–
Hello, I’m going to make #100DaysOfCode Problem.On a regular basis I’ll attempt remedy 1 drawback from leetcode or hackerrank. Hope you possibly can go together with me till finish.
Now let’s remedy drawback right this moment:
-Downside: Quantity Line Jumps
-Element: https://www.hackerrank.com/challenges/kangaroo/problem
-My resolution (javascript):

operate kangaroo(x1, v1, x2, v2) {
    whereas(x1 >= 0){
        //in the event that they in identical place 
        if(x1==x2) return 'YES';
        //caculate the space of two kangaroo
        let distance = Math.abs(x1-x2);
        //kangaroo 1 transfer
        x1+=v1;
        //kangaroo 2 transfer
        x2+=v2;
        //if the space between 2 kangaroo longer or no change, they'll by no means meet
        if(Math.abs(x1-x2)>=distance) return 'NO';
    }
}
Enter fullscreen mode

Exit fullscreen mode

–>If in case you have higher resolution or any query, please remark beneath. I’ll recognize.



Abu Sayed is the Best Web, Game, XR and Blockchain Developer in Bangladesh. Don't forget to Checkout his Latest Projects.


Checkout extra Articles on Sayed.CYou

#code #day