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.
The problem statement says consecutive steps below sea level. Does this solution work for 4 DUDU or does it return 1? Based on the problem statement that input should return 0.
Edit: I removed the condition to check that the previous step was also below sea level and all the tests passed. However, this no longer matches the definition of a valley "consecutive steps below sea-level"... unless I am misunderstanding the implied multiplicity in the word consecutive.
Counting Valleys
You are viewing a single comment's thread. Return to all comments →
The problem statement says consecutive steps below sea level. Does this solution work for 4 DUDU or does it return 1? Based on the problem statement that input should return 0.
Edit: I removed the condition to check that the previous step was also below sea level and all the tests passed. However, this no longer matches the definition of a valley "consecutive steps below sea-level"... unless I am misunderstanding the implied multiplicity in the word consecutive.