Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
문제
풀이 후기
명령어마다 string을 변경해주는 방법으로 했다가 시간 초과가 났다
아마 slice의 시간복잡도가 O(n)인 것 때문인 것 같다
도저히 시간복잡도를 줄일 방법을 모르겠어서 서치를 해서 cursor를 기준으로 양 쪽에 스택을 두고 푸는 방법이 있다는 것을 알게 되어 그대로 구현했다.
스택의 push pop 연산이 O(1)이기 때문에 이 문제에서 활용할 수 있었다.
스스로 생각해내지 못해 안타깝지만 그래도 스택을 이렇게도 활용할 수 있다는 것을 알게 된 것에 의미를 두자!