-
[백준] 9935 - 문자열 폭발 (파이썬)알고리즘/백준 2021. 9. 23. 16:19
array = list(input()) check = list(input()) total = [] for i in range(len(array)): if len(total) >= len(check): total.append(array[i]) t = 0 for j in range(-len(check),0,1): if total[j] != check[j]: t = 1 break if t == 0: for _ in range(len(check)): total.pop() else: total.append(array[i]) if len(total) >= len(check): t = 0 for j in range(-len(check),0,1): if total[j] != check[j]: t = 1 break if t == 0: for _ in range(len(check)): total.pop() if len(total) == 0: print('FRULA') else: a = "".join(total) print(a)
스택을 통해 접근
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 11052 - 카드 구매하기 (파이썬) (0) 2021.09.23 [백준] 11048 - 이동하기 (파이썬) (0) 2021.09.23 [백준] 9663 - N-Queen (파이썬) (0) 2021.09.23 [백준] 9251 - LCS (파이썬) (0) 2021.09.23 [백준] 7453 - 합이 0인 네 정수 (파이썬) (0) 2021.09.23