• + 0 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!