You are viewing a single comment's thread. Return to all comments →
Using Python:
def countingValleys(steps, path): altitude = 0 nValleys = 0 for i in range(steps): step = path[i] if step == "U": altitude += 1 else: altitude -=1 if altitude == 0: if step == "U": nValleys += 1 return nValleys
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 →
Using Python: