[HackerRank] Counting Valleys
703 단어 hackerrankhackerrank
[문제 링크]
[입력]
int steps: the number of steps on the hike
string path: a string describing the path
[출력]
int: the number of valleys traversed
[코드]
def countingValleys(steps, path):
# Write your code here
result = 0
pos = 0
for i in range(steps):
if path[i] == 'U':
pos +=1
else:
if pos==0:
result +=1
pos -=1
return result
Author And Source
이 문제에 관하여([HackerRank] Counting Valleys), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jongmin97/HackerRank-Counting-Valleys저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)