Solving Counting Valleys Challenge

Nicole Guzmán
Nov 29, 2020

I think it’s one of the easiest challenge I faced on Hacker Rank… when you understand what you have to do. Actually, I read some papers about the problem because I didn’t understand it well until I read the problem again.

I know, that’s a silly challenge but, sometimes, we should stop with the rush and read a problem like for real.

So, what I understood after read it the second time was: I need to know when the person go down after being in sea level ( which is 0) so, the only thing I had to do was asking if the current level is 0 and the next step is D. Pretty straightforward.

So, the code:

I hope you like!

Thanks for reading!

--

--