We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Counting Valleys
- Discussions
Counting Valleys
Counting Valleys
Sort by
recency
|
176 Discussions
|
Please Login in order to post a comment
My TypeScript solution:
A rust solution:
Hey folks, In this problem, the only confusion part is, if the level is 0 and the step is 'D'(that is down), why we are incrementing the valley count? The answer is we are pretty much looking for the valley. In this case, valley is step down and the sea level is 0. So from the sea level to enters into valley is taken as count one, then because of the problem statement, the hiker definitely needs to reach the sea level after some steps later. Here is the solution in javascript,
def countingValleys(steps, path):