Jae-Kyung Cho LLM Developers who was a Robotics engineer

Baekjoon-9935-문자열 폭발

Python 의 연산 시간이 C++에 비해서 10배는 넘는 것 같다.
그건 그렇고 아래 두개가 연산시간이 꽤나 차이가 난다.

stack = stack[:-len(bomb)]
del stack[-len(bomb):]

알아두도록 하자.

string = input().strip()
bomb = input().strip()

stack = []
for char in string:
    stack.append(char)
    if char == bomb[-1]:
        isBomb = True
        for i in range(1,len(bomb)+1):
            if i>len(stack) or bomb[-i]!=stack[-i]:
                isBomb=False
                break
        if isBomb:
            del stack[-len(bomb):]

if len(stack) == 0:
    print("FRULA")
else:
    print(*stack,sep='')
Comments