You are viewing a single comment's thread. Return to all comments →
def countingValleys(steps, path): valleys = 0 height = 0 step = 0 for i in path: print(height) if i == 'U': step = 1 elif i == 'D': step = -1 if height == 0 and step == -1: valleys += 1 height += step return valleys
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 →