백준 4575번: Refrigerator Magnets #Python

ColorlessDia·2024년 8월 3일

algorithm/baekjoon

목록 보기
258/807
import sys

while True:
    sentence = sys.stdin.readline().rstrip()

    if sentence == 'END':
        break
    
    alphabat_count = [0] * 26
    is_possible = True

    for char in sentence:
        
        if char == ' ':
            continue

        index = ord(char) - ord('A')

        alphabat_count[index] += 1

        if 1 < alphabat_count[index]:
            is_possible = False
            break
    
    if is_possible:
        print(sentence)

0개의 댓글