본문 바로가기
개발공부/문제풀기

백준 1259 - 팰린드롬수

by 맙소사 2022. 3. 17.

어제 풀었던 팰린드롬( https://www.acmicpc.net/problem/1259 )

근데 이거 와일문에 포문이 두 개나 들어있어서 너무나... 시간이 비효율적인것 같고

주말에 시간 나면 다시 고쳐보도록 하자

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def palindrome() :
 
    while True :
        text = str(input())
        if text == '0':
            break
        reverse = ""
        stack = []
        for i in text :
            stack.append(i)
 
        for s in text :
            reverse += stack.pop()
 
        if text == reverse :
            print("yes")
        else :
            print("no")
 
 
palindrome()
cs

'개발공부 > 문제풀기' 카테고리의 다른 글

백준 2525 - 오븐시계  (0) 2022.03.20
백준 2231 - 분해합  (0) 2022.03.17
백준커리큘럼  (0) 2022.01.18
백준 2916번 - 저작권  (0) 2021.11.18
백준 11283번 - 한글2  (0) 2021.11.11

댓글