개발공부/문제풀기
백준 1259 - 팰린드롬수
맙소사
2022. 3. 17. 21:51
어제 풀었던 팰린드롬( 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 |