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
|
178 Discussions
|
Please Login in order to post a comment
This is a classic stack solution. My answer in Kotlin:
The catch is: when we have an empty stack we are in sea level, then if we receive a 'D', we enter a Valley, and will stay inside a valley until the stack is empty again. Same thing for a mountain.
My TypeScript solution:
A rust solution: