Wednesday, August 30, 2017

CodeForces: New Year Transportation(500 A) Solution in Java for Beginners

 New Year Transportation(500 A) Problem Link

The solution is found in the problem, so I suggest you try it by yourself.
If you need a quick reminder for while loop, check out this youtube video of newBoston.
You can find tutorial for if-else , in this tutorialspoint page about if-else.


New Year Transportation(500 A) Solution Link

If you are facing problems solving this , now you can come here for the solution. So after taking the necessary input, you begin from the first index (currentIndex - set to 1). Then you enter a while loop. Here on every iteration you check whether you've reached your destination, on which case done variable will be true. If currentIndex > destination, you'll never get to destination since you can't travel backwards. In this case you just break out of the loop. The loop will terminate once you've traversed the whole array.

Finally you check  whether done is true (you've reached your destination) or false(otherwise).

Check out my other codeforces solutions in  under codeforces label.

1 comment:

  1. Hi,

    Useful post. Very well explained. Thanks for sharing.



Beginner's Guide: Some Useful Machine Learning Websites(Part 1)

I have been away for quite some time now. The reason is I was quite busy with my academic thesis and general academic pressure. Now I do fe...