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.
๐ ๋ฌธ์ ๋งํฌ
๋ฐฑ์ค | ๋๋์ผ ํฌ์ผ๋ชฌ ๋ง์คํฐ ์ด๋ค์
โ๏ธ ์์๋ ์๊ฐ
30๋ถ
โจ ์๋ ์ฝ๋
์ด๋ฒ์๋ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ํ์ฉํด์ ํ์ด๋ดค์ต๋๋ค!!
๋ฐฑ์ค ๋ค์ด๊ฐ๋ณด์๋ฉด ๋ฌธ์ ๊ฐ ์ข ๋ณ๋ง(?)์ธ ๊ฒ ๊ฐ์๋ฐ ์ ๋ ฅ๋ถ๋ถ๋ถํฐ ๋ณด์๋ฉด ์ ์์ ์ธ ๋ฌธ์ ์ ๋๋ค!!
1๏ธโฃ ์ ๋ ฅ ํ์ฑ
์ ๋ ฅ๋ฐ์ ๋ฐ์ดํฐ๋ฅผ "\n" ๊ธฐ์ค์ผ๋ก ๋จผ์ ๋๋ ๋ฐฐ์ด input์ผ๋ก ๋ง๋ค์ด์ค๋๋ค.
input ๋ฐฐ์ด์ ์ฒซ๋ฒ์งธ ์์๋ฅผ " "๊ธฐ์ค์ผ๋ก ๋๋์ด ๋ฐฐ์ด๋ก ๋ง๋ค๊ณ , ๊ทธ ๋ฐฐ์ด์ ์ฒซ๋ฒ์งธ ์์๋ฅผ N์ผ๋ก ์ค์ ํฉ๋๋ค.
input ๋ฐฐ์ด์ ๋๋ฒ์งธ ์์๋ถํฐ N์์ ๊น์ง๋ฅผ ๋ผ์
pokemonList
๋ฐฐ์ด๋ก ๋ง๋ค์ด์ค๋๋ค.input ๋ฐฐ์ด์ 1+N์์๋ถํฐ ๋๊น์ง๋ฅผ ๋ผ์
testList
๋ฐฐ์ด๋ก ๋ง๋ค์ด์ค๋๋ค.2๏ธโฃ map์ ํ์ฉํด ํฌ์ผ๋ชฌ ์ด๋ฆ๊ณผ ๋ฒํธ ์ ์ฅ
Map ์๋ฃ๊ตฌ์กฐ๋ฅผ ํ์ฉํ์ฌ ํฌ์ผ๋ชฌ ์ด๋ฆ์ Key, ํฌ์ผ๋ชฌ ๋ฒํธ๋ฅผ Value๋ก ์ ์ฅํฉ๋๋ค.
ํด์๋งต์ ํ์ฉํ๋ฉด ํฌ์ผ๋ชฌ ์ด๋ฆ์ ์ธ๋ฑ์ค์ฒ๋ผ ์ ๊ทผํด ํฌ์ผ๋ชฌ ๋ฒํธ๋ฅผ ๋ฐ์์ฌ ์ ์์ต๋๋ค.
pokemonMap์ ๋ง๋ค์ด์ฃผ๊ณ , ์์์ ๋ง๋ pokemonList๋ฐฐ์ด์ ๋๋ฉด์ Key, value๋ฅผ ์ ํด ๋ฃ์ด์ค๋๋ค.
3๏ธโฃ ํฌ์ผ๋ชฌ ๋ฌธ์ ์ ๋ํ ๋ต ์ถ๋ ฅํ๊ธฐ
๋จผ์ ๋ต์ ์ ์ฅํ ๋น๋ฌธ์์ด์ ๋ง๋ค์ด์ค๋๋ค.
testList๋ฅผ ์ํํ๋ฉด์
๋ง์ฝ ์์๊ฐ ์ซ์๋ผ๋ฉด pokemonList์์ ํด๋น ์ซ์ - 1์ ์ธ๋ฑ์ค์ ์ ๊ทผํด ์ด๋ฆ์ ๋ฌธ์์ด์ ์ถ๊ฐ
๋ง์ฝ ์์๊ฐ ๋ฌธ์๋ผ๋ฉด pokemonMap์์ ํด๋น ๋ฌธ์๋ฅผ ํค๋กํ์ฌ ๋ฒํธ ๊ฐ์ ๋ฌธ์์ด์ ์ถ๊ฐ
์ํ๊ฐ ๋๋๋ฉด ๋ง๋ค์ด์ง ๋ฌธ์์ด์ ์ถ๋ ฅํด์ค๋๋ค.
๐ ์ ์ฒด ์ฝ๋
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
์๋ฐ์คํฌ๋ฆฝํธ์์ ๋น ๋ฅธ ์ถ๋ ฅ์ ํ๊ธฐ ์ํด์๋
console.log()
๋ฅผ ์ต๋ํ ์ ๊ฒ ์ฌ์ฉํด์ผ ๋จ์ ๋ฐฐ์ ์ต๋๋ค.์ฒ์ ์ถ๋ ฅ์ ์ฐพ์๋๋ง๋ค console.log()๋ก ์ ๋ต์ ์ถ๋ ฅํด์ฃผ๋ ๋ฐฉ๋ฒ์ด์๋๋ฐ ์๊ฐ์ด ๋ง์ด ๊ฑธ๋ ธ์ต๋๋ค.
๋๋ฒ์งธ ํ์ด ๊ทธ๋์ ์๊ฐํด๋ธ๊ฒ ์์ 3๋ฒ ๊ณผ์ ์์ ์ฌ์ฉํ ์ถ๋ ฅ ๋ฌธ์์ด์ ๋ง๋ค์ด์ ํ๋ฒ์ ์ถ๋ ฅํ๋ ๋ฐฉ์์ ๋๋ค.