그냥 방향 바뀌는 부분만 체크해주면 댄당
import sys
input = sys.stdin.readline
N = int(input())
maps = input()
cnt = 1
for i in range(1,N):
if maps[i]=='E':
if maps[i-1]=='W':
cnt +=1
print(cnt)
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 14442 벽 뿌수고 이동하기2 (1) | 2021.08.30 |
---|---|
[백준][Python] 14938 서강그라운드 (0) | 2021.08.30 |
[백준][Python] 13418 학교탐방가기 (0) | 2021.08.29 |
[백준][Python] 15724 주지수 (0) | 2021.08.29 |
[백준][Python] 14621 나만안되는 연애 (0) | 2021.08.29 |