def countingValleys(steps, path):
# Write your code here
result = 0
check = 0
for p in path:
if p == 'U':
if check + 1 == 0:
result += 1
check += 1
else:
check -= 1
return result
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
[HackerRank-python] Cats and a Mouse (0) | 2022.07.10 |
---|---|
[HackerRank-python] Electronics Shop (0) | 2022.07.10 |
[HackerRank-python] Drawing Book (0) | 2022.07.07 |
[HackerRank-Python] Sales by Match (0) | 2022.07.07 |
[HackerRank-python] Bill Division (0) | 2022.07.03 |