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.
๐ ๋ฌธ์ ๋งํฌ
reverse-substrings-between-each-pair-of-parentheses
โ๏ธ ์์๋ ์๊ฐ
3์๊ฐ
โจ ์๋ ์ฝ๋
๋ฌธ์ ์ค๋ช
๋ฌธ์์ด
s
๊ฐ ์ฃผ์ด์ง๋ค.s
๋ ์๋ฌธ์์(
,)
๋ก ์ด๋ฃจ์ด์ง ๋ฌธ์์ด์ด๋ค.๊ฐ ๊ดํธ๋ Layer์ ๊ฐ์ ์ญํ ์ ํ๋ค.
์ฒ์์๋ ๋ฌธ์์ด์ด ์์๋๋ก ๋์ค์ง๋ง
(
๊ฐ ์์๋๋ ์๊ฐ ํด๋น Layer์ ์๋ ๋ฌธ์์ด๋ค์ ์์๊ฐ ๋ค์งํ๋ค.ํ์ด ๋ฐฉ๋ฒ
)
๋ฅผ ์ ์ธํ ๋ฌธ์๋ค์ ์คํ์๋ค๊ฐ ์ง์ด๋ฃ๋๋ค.)
๋ฅผ ๋ง๋ฌ์ ๋ ์คํ์ ์กด์ฌํ๋ ๋ชจ๋ ๋ฌธ์๋ฅผword
๋ณ์์ ๋ฃ๊ณ ๋ค์ ์คํ์๋ค๊ฐ ์ง์ด ๋ฃ๋๋ค. (=> ๋ฌธ์์ด์ ํ๋ฒ ๋ค์ง์)๋จ, ์ฃผ์ํด์ผํ ์
s = "(abcd)"
stack = a <- b <- c <- d ๋ก ์ ์ฅ๋๋ค.
)
๋ฅผ ๋ง๋๊ฒ๋๋ฉดword = dcba
stack = d<-c<-b<-a๋ก ์ ์ฅ๋๋ค.
์ถ๋ ฅํ ๋ ํ๋ฒ ๋ ๋ค์ง์ด์ฃผ๋ฉด d c b a๋ก ์ถ๋ ฅ์ด ๋๊ฒ ๋๋ค! => ans = stack->top() + ans;
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ