You are viewing a single comment's thread. Return to all comments →
def countingValleys(steps, path): level = 0 valley = False path_values = list(map(direction_value, path)) valleys = 0 for s in path_values: level += s if level < 0: valley = True if valley and level >= 0: valleys += 1 valley = False return valleys def direction_value(d): if d == 'U': return 1 return -1
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 →