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.
๐ ๋ฌธ์ ๋งํฌ
16934 ๊ฒ์ ๋๋ค์
โ๏ธ ์์๋ ์๊ฐ
30๋ถ
โจ ์๋ ์ฝ๋
1. ๋ฌธ์
์ด ๋ฌธ์์ด๋ค์ ์ด์ฉํด ๋ด๋ถ์ ์ ์ฅํ ๋ณ์นญ์ ๋ง๋ค๊ณ ์ ํ๋ค. ๋ณ์นญ์ ๋ค์๊ณผ ๊ฐ์ ๊ท์น์ผ๋ก ๊ตฌ์ฑํ๋ค.
์๋ฅผ ๋ค์ด$N = 5$ ์ด๊ณ ๋ฌธ์์ด๋ค์ด ["baekjoon", "startlink", "bakejoon", "beakjoon", "baekjoon"] ์ฃผ์ด์ก๋ค๋ฉด
N๊ฐ์ ๋ฌธ์์ด์ด ์ฃผ์ด์ก์ ๋, ๋ค์ด์จ ์์๋๋ก ๋ณ์นญ์ ํ ์ค์ ํ๋์ฉ ์ถ๋ ฅํ๋ผ.
2. ์ค๋ช
์ค๋ช ๋ง ๋ณด๋ฉด Trie ์๋ฃ๊ตฌ์กฐ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ฐ์ฅ ์ ์ ํด๋ณด์ด๊ธด ํ๋, N์ ํฌ๊ธฐ์ ๊ฐ ๋ฌธ์์ด์ ๊ธธ์ด๊ฐ ํฌ์ง ์์ ๋จ์ํ Set/Map(Dictionary)์ ์ฌ์ฉํด๋ ํ์ด๊ฐ ๊ฐ๋ฅํ๋ค.
์ฐ์ ๋ฌธ์์ด์ด ์ฃผ์ด์ง๋ฉด ํด๋น ๋ฌธ์์ด์ ๊ธธ์ด๊ฐ 1, 2, 3, ...์ธ ๋ถ๋ถ ๋ฌธ์์ด๋ก ๋ผ์ ์ ์ฅ์์ผ์ผ ํ๋ค.
์ด ๊ณผ์ ์์ ๋ง์ฝ Storage์ ์ ์ฅ๋์ง ์์ ๋ณ์นญ์ด ๋ฐ๊ฒฌ๋๋ค๋ฉด ์ฌ์ฉํ ์ ์์์ ์๋ฏธํ๋ฏ๋ก ์ถ๋ ฅํ๋ค.
๋ง์ฝ ์ ๋ฐ๋ณต๋ฌธ์ ๋๊น์ง ๋์๋๋ฐ๋ ์ถ๋ ฅํ์ง ๋ชปํ ๊ฒ์ด๋ฉด "์ค๋ณต๋ ๋ฌธ์์ด"์ด ๋ค์ด์์์ ์๋ฏธํ๋ค.
์ด ๊ฒฝ์ฐ "๋ช ๊ฐ ๋ค์ด์๋ ์ง"๋ฅผ ์์์ผ ํ๊ธฐ ๋๋ฌธ์ ๋ฌธ์์ด์ Key๋ก ํด์ ๊ฐ์๋ฅผ ์นด์ดํธ ํ๋ Map์ ์ด์ฉํ๋ค.
IsPrint == false
๋ก ์ธํด ๋ณ์นญ์ด "ab1"์ผ๋ก ๋๋ค.3. ์ ์ฒด ์ฝ๋
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
๋ฌธ์ ์ด๋ฆ์ด ์ฌ๋ฐ์ด ๋ณด์ฌ์ ๊ณจ๋๋๋ฐ ์์ ์ ํผ 5052 ์ ํ๋ฒํธ ๋ชฉ๋ก ๋ฌธ์ ์ ๊ฑฐ์ ์ ์ฌํด์ ํ ํฐ๋ ์คํ ...