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.
Great explanation of counting valleys here! The logic—tracking altitude changes and recognizing when you're exiting a valley (i.e. going from below sea level back to zero)—is spot on. It’s really helpful to see the condition if (level == 0 && step == 'U') ++valleys; clearly broken down.
By the way, if anyone’s working on code challenges while planning overseas travel or residency, you might also be juggling documentation like police clearance. For instance, those applying in the Philippines often need a police clearance to show good conduct. Just a friendly heads-up for anyone balancing coding tasks and bureaucracy!
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 →
Great explanation of counting valleys here! The logic—tracking altitude changes and recognizing when you're exiting a valley (i.e. going from below sea level back to zero)—is spot on. It’s really helpful to see the condition if (level == 0 && step == 'U') ++valleys; clearly broken down.
By the way, if anyone’s working on code challenges while planning overseas travel or residency, you might also be juggling documentation like police clearance. For instance, those applying in the Philippines often need a police clearance to show good conduct. Just a friendly heads-up for anyone balancing coding tasks and bureaucracy!