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
Counting Valleys
Sort by
recency
|
4144 Discussions
|
Please Login in order to post a comment
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!
My solution c++
} `
Sorry, I didn't get the question. The mention is "A valley is a sequence of consecutive steps below sea level,"
Considering String "DUDDDUUDUU", I see only one conecutive substring with D's. So, I am expecting the answer to be 1. How come the original answer is 2. Please help