백준 21945번: Palindromes #Python

ColorlessDia·2026년 1월 9일

algorithm/baekjoon

목록 보기
783/807
def is_palindrome(s):

    for i in range(len(s) // 2):
        f, b = s[i], s[-(i + 1)]

        if f != b:
            return False

    return True

N = int(input())
string_sequence = input().rstrip().split()

count = 0

for string in string_sequence:
    
    if is_palindrome(string):
        count += int(string)

print(count)

0개의 댓글