Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Complete the countingValleys function below.
- def countingValleys(n, s):
- tot_valley = 0
- current_level = 0
- hike = list(s)
- for cur_step in hike:
- if cur_step == 'U':
- current_level += 1
- elif cur_step == 'D':
- if current_level == 0:
- tot_valley += 1
- current_level -= 1
- return tot_valley
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement