CodingTest/solved - Python
[SWEA D2] 1989. 초심자의 회문 검사
dayae_dev
2024. 5. 3. 16:53
https://swexpertacademy.com/main/code/problem/problemDetail.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
문제 해결 방법 및 코드 구현
t = int(input())
for i in range(t):
stringg = input()
stackk = []
check = 0
prin = ""
if len(stringg) % 2 == 0:
#짝수
checkN = (len(stringg) // 2) - 1
for idx, j in enumerate(stringg):
if idx <= checkN:
stackk.append(j)
else:
if stackk.pop() == j:
check = 1
else:
check = 0
else:
#홀수
checkN = (len(stringg) - 1) // 2
for idx, j in enumerate(stringg):
if idx < checkN:
stackk.append(j)
elif idx == checkN:
pass
else:
if stackk.pop() == j:
check = 1
else:
check = 0
prin +="#"+str(i+1)+" "+str(check)
print(prin)
시간/공간 복잡도
최악의 경우 O(N)
최적화 및 개선
따로 하지않음
어려웠던 점 / 느낀점
D3으로 가야겠다.