← Amazon questions

Count mountains and valleys from string

Filed under Amazon

Given a string of 'U' (up) and 'D' (down) representing steps, count the number of mountains (sequences starting at sea level, going above, and returning) and valleys (sequences going below sea level…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.