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.
d[i] is value not key.
The logic is brilliant. a is taking the sum of the consequitive steps of the path.So, after decending a valley if someone ascending to sea level then a=0 and if again it is negative that means new valley is explored so b will be increased 1 otherwise no change.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Valleys
You are viewing a single comment's thread. Return to all comments →
d[i] is value not key. The logic is brilliant. a is taking the sum of the consequitive steps of the path.So, after decending a valley if someone ascending to sea level then a=0 and if again it is negative that means new valley is explored so b will be increased 1 otherwise no change.