728x90
반응형
find를 통해 뒷 글자와 앞 글자의 위치를 비교하면 된다.
단어의 모든 구간에서 뒷 글자의 위치가 앞 글자의 위치보다 크다면 그룹 단어이다.
# find는 원하는 글자의 제일 앞 위치를 알려준다.
EX) 'jinhoiii'.find('i') = 1
result = int(input())
for _ in range(result):
word = input()
for i in range(1, len(word)):
if word.find(word[i-1]) > word.find(word[i]):
result -= 1
break
print(result)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 1357번 뒤집힌 덧셈(python) (0) | 2020.01.26 |
---|---|
백준 알고리즘 1330번 두 수 비교하기(python) (0) | 2020.01.26 |
백준 알고리즘 1297번 TV 크기(python) (0) | 2020.01.26 |
백준 알고리즘 1193번 분수찾기(python) (0) | 2020.01.26 |
백준 알고리즘 1181번 단어 정렬(python) (0) | 2020.01.26 |