From e6cb45399e63663e8d026294fb8b402633617aa9 Mon Sep 17 00:00:00 2001 From: 4Bee <109135643+4BFC@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:26:11 +0900 Subject: [PATCH 01/16] =?UTF-8?q?=F0=9F=94=80:=20recently=20=EB=B8=8C?= =?UTF-8?q?=EB=A0=8C=EC=B9=98=EB=A5=BC=20=EC=B5=9C=EC=8B=A0=ED=99=94=20?= =?UTF-8?q?=ED=95=98=EA=B8=B0=EC=9C=84=ED=95=9C=20merge=20=20(#49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ๐Ÿ”€: 2750 retry(1) (#12) * ๐Ÿšฉ: ๋ฌธ์ œ๋ฅผ ํ’€๊ธฐ์œ„ํ•œ ์„ธํŒ… * ๐Ÿšฉ: PR ํ…œํ”Œ๋ฆฟ ์ƒ์„ฑ ๋ฌธ์ œ๋กœ ํŒŒ์ผ ์‚ญ์ œ * ๐Ÿšฉ: bubble ์ •๋ ฌ ์ ์šฉ ๋ฐ ์ •๋ ฌ ํ™•์ธ * ๐Ÿšฉ: ๋ฐฐ์—ด ์ค‘๋ณต์ œ๊ฑฐ ๋กœ์ง ๊ตฌํ˜„ ์˜ค๋‹ต * ๐ŸŒฑ : PR ํ…œํ”Œ๋ฆฟ ์žฌ์ƒ์„ฑ * ๐Ÿ›: sort์™€ filter ๊ทธ๋ฆฌ๊ณ  indexOf ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ ์‹œ๋„, ์˜ค๋‹ต * ๐Ÿ›: shift์™€ trim์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ, pop์œผ๋กœ ๋ฌธ์ œ๋ฅผ ์‹œ๋„ ํ–ˆ์œผ๋‚˜ ์˜ค๋‹ต ์™œ์ธ์ง€ ์•„์ง ๋ช…ํ™•ํ•˜์ง€ ์•Š๋‹ค. * ๐Ÿšฉ: ์ฃผ์„์ œ๊ฑฐ * ๐Ÿ”€: 1181 (#14) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: shift์™€ sort๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ •๋ ฌ ์‹œ๋„ * ๐Ÿšฉ: sort์˜ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ ์„ค์ •์„ ํ†ตํ•ด์„œ ๋ฐฐ์—ด ๊ธธ์ด ์ˆœ์œผ๋กœ ์ •๋ ฌ ์‹œ๋„ * ๐Ÿšฉ: sort ๋น„๊ตํ•จ์ˆ˜๋ฅผ if๋ฌธ์œผ๋กœ ์•ŒํŒŒ๋ฒณ, ๋ฌธ์ž์—ด ๊ธธ์ด ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ์ด ๋  ์ˆ˜ ์žˆ๊ฒŒ ๋ฌธ์ œ ํ•ด๊ฒฐ * ๐Ÿ”€: 10798 (#16) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: ์ด์ค‘ for๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ ์‹œ๋„ * ๐Ÿ›: ์ฒซ ๋ฒˆ์งธ ์˜ˆ์ œ ์ž…๋ ฅ1์€ ๋งž์ง€๋งŒ ์˜ˆ์ œ ์ž…๋ ฅ2๋Š” ์˜ค๋‹ต * ๐Ÿ›: ๋ฐฑ์ค€์€ ์ •๋‹ต์ด์ง€๋งŒ vsc์—์„œ ์ถœ๋ ฅ๋˜๋Š” ์˜ค๋‹ต๊ณผ ํ’€๋ฆฌ์ง€ ์•Š์€ ์˜๋ฌธ * ๐Ÿ”€: 11650 (#19) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: ์ด์ค‘ for๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ์‹œ๋„ * ๐Ÿšฉ: sort ์กฐ๊ฑด๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ์‹œ๋„ ์˜ค๋‹ต * ๐Ÿšฉ: x,y ์ •๋ ฌ ์ˆœ์„œ ๋ฐ ๊ธฐ์ค€์„ ์ˆ˜์ •ํ•ด์„œ ๋ฌธ์ œ ์‹œ๋„ ์ •๋‹ต * ๐Ÿ”€: 2839 (#30) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: ๋ฌธ์ œ์— ์ฃผ์–ด์ง„ ์กฐ๊ฑด๋“ค์„ ๋Œ€์ž…ํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด์ง€๋งŒ ์†Œ์ˆ˜์ ์„ ์ปจํŠธ๋กคํ•˜๋Š” ๋ถ€๋ถ„์ด ๋ฏธํก * ๐Ÿšฉ: ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ˆœํ™˜์„ ํ–ˆ์ง€๋งŒ ๊ฒฐ๊ณผ๋Š” ์˜๋„์™€ ๋‹ฌ๋ฆฌ ๋‚˜์˜จ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ œ์˜ ์กฐ๊ฑด ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์˜ˆ์ƒ์ถœ๋ ฅ์˜ ์กฐ๊ฑด ๋˜ํ•œ ์ž˜ ํŒŒ์•…์„ ํ•ด์•ผํ•œ๋‹ค. * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” ๋ฐ ๋ถ„์„ ํ•„์š” * ๐Ÿ”€: 2839 retry(1) (#32) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: ๋ฌธ์ œ์— ์ฃผ์–ด์ง„ ์กฐ๊ฑด๋“ค์„ ๋Œ€์ž…ํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด์ง€๋งŒ ์†Œ์ˆ˜์ ์„ ์ปจํŠธ๋กคํ•˜๋Š” ๋ถ€๋ถ„์ด ๋ฏธํก * ๐Ÿšฉ: ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ˆœํ™˜์„ ํ–ˆ์ง€๋งŒ ๊ฒฐ๊ณผ๋Š” ์˜๋„์™€ ๋‹ฌ๋ฆฌ ๋‚˜์˜จ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ œ์˜ ์กฐ๊ฑด ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์˜ˆ์ƒ์ถœ๋ ฅ์˜ ์กฐ๊ฑด ๋˜ํ•œ ์ž˜ ํŒŒ์•…์„ ํ•ด์•ผํ•œ๋‹ค. * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” ๋ฐ ๋ถ„์„ ํ•„์š” * ๐Ÿ›: ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ์œผ๋กœ ์˜ค๋‹ต * ๐Ÿ›: ๋งˆ์ง€๋ง‰ ์กฐ๊ฑด๋ฌธ์„ ๋ณ€๊ฒฝํ•จ์œผ๋กœ ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ ํ†ต๊ณผ, ์˜ค๋‹ต * ๐Ÿ›: ์ฝ”๋“œ ์ˆ˜์ •์œผ๋กœ ์˜ˆ์ œ ์ž…๋ ฅ 4๋ฒˆ์—์„œ ์˜ค๋‹ต ํ›„ ํ•ด๊ฒฐ ๋‹จ, ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์ด์œ  ์„ค๋ช… ํ•„์š”. ์ •๋‹ต * ๐Ÿšฉ: ๋ฌธ์ œ์˜ ๊ธฐ๋ณธ ์กฐ๊ฑด์‹์˜ ํ‹€ ์ƒ์„ฑ * ๐Ÿšฉ: ์˜ˆ์‹œ์ž…๋ ฅ1๋ฒˆ์— ๋งž๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ, ์˜ˆ์‹œ์ž…๋ ฅ1๋ฒˆ ํ†ต๊ณผ * ๐Ÿšฉ: ์˜ˆ์ œ ์ž…๋ ฅ5๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ์˜ˆ์ œ ์ž…๋ ฅ ํ†ต๊ณผ * ๐Ÿšฉ: ์˜ˆ์ œ์ž…๋ ฅ 5๋ฒˆ๊ณผ 2๋ฒˆ ๋ถˆํ†ต๊ณผ ๋ฌธ์ œ ํ•ด๊ฒฐ * ๐Ÿšฉ: ์˜ค๋‹ต * ๐Ÿšฉ: ๋ถˆํ•„์š”ํ•˜๊ฒŒ result๊ฐ‘์ด ์ฆ๊ฐ€๋œ๋‹ค. ์ด์— ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง„๋‹ค. * ๐Ÿ”€: 2839 retry(2) (#35) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐Ÿšฉ: ๋ฌธ์ œ์— ์ฃผ์–ด์ง„ ์กฐ๊ฑด๋“ค์„ ๋Œ€์ž…ํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด์ง€๋งŒ ์†Œ์ˆ˜์ ์„ ์ปจํŠธ๋กคํ•˜๋Š” ๋ถ€๋ถ„์ด ๋ฏธํก * ๐Ÿšฉ: ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ˆœํ™˜์„ ํ–ˆ์ง€๋งŒ ๊ฒฐ๊ณผ๋Š” ์˜๋„์™€ ๋‹ฌ๋ฆฌ ๋‚˜์˜จ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ œ์˜ ์กฐ๊ฑด ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์˜ˆ์ƒ์ถœ๋ ฅ์˜ ์กฐ๊ฑด ๋˜ํ•œ ์ž˜ ํŒŒ์•…์„ ํ•ด์•ผํ•œ๋‹ค. * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” * ๐Ÿšฉ: ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝํ•˜๋ฉด ์›ํ•˜๋Š” ์ •๋‹ต์„ ๋„์ถœ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์ • ํ•„์š” ๋ฐ ๋ถ„์„ ํ•„์š” * ๐Ÿ›: ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ์œผ๋กœ ์˜ค๋‹ต * ๐Ÿ›: ๋งˆ์ง€๋ง‰ ์กฐ๊ฑด๋ฌธ์„ ๋ณ€๊ฒฝํ•จ์œผ๋กœ ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ ํ†ต๊ณผ, ์˜ค๋‹ต * ๐Ÿ›: ์ฝ”๋“œ ์ˆ˜์ •์œผ๋กœ ์˜ˆ์ œ ์ž…๋ ฅ 4๋ฒˆ์—์„œ ์˜ค๋‹ต ํ›„ ํ•ด๊ฒฐ ๋‹จ, ์˜ˆ์ œ ์ž…๋ ฅ 5๋ฒˆ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์ด์œ  ์„ค๋ช… ํ•„์š”. ์ •๋‹ต * ๐Ÿšฉ: ๋ฌธ์ œ์˜ ๊ธฐ๋ณธ ์กฐ๊ฑด์‹์˜ ํ‹€ ์ƒ์„ฑ * ๐Ÿšฉ: ์˜ˆ์‹œ์ž…๋ ฅ1๋ฒˆ์— ๋งž๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ, ์˜ˆ์‹œ์ž…๋ ฅ1๋ฒˆ ํ†ต๊ณผ * ๐Ÿšฉ: ์˜ˆ์ œ ์ž…๋ ฅ5๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ์˜ˆ์ œ ์ž…๋ ฅ ํ†ต๊ณผ * ๐Ÿšฉ: ์˜ˆ์ œ์ž…๋ ฅ 5๋ฒˆ๊ณผ 2๋ฒˆ ๋ถˆํ†ต๊ณผ ๋ฌธ์ œ ํ•ด๊ฒฐ * ๐Ÿšฉ: ์˜ค๋‹ต * ๐Ÿšฉ: ๋ถˆํ•„์š”ํ•˜๊ฒŒ result๊ฐ‘์ด ์ฆ๊ฐ€๋œ๋‹ค. ์ด์— ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง„๋‹ค. * ๐Ÿ”€: Algorithm/dynamic programming (#40) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐ŸŒฑ: README์„ ์ˆ˜์ • GitHub์—์„œ ์ง์ ‘ ์ˆ˜์ •ํ•œ issue ์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: printer.js ํŒŒ์ผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: PRํ…œํ”Œ๋ฆฟ์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: PR-TEMPLATE๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: issue templates ์ˆ˜์ • Github์—์„œ ์ž‘์„ฑ๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐Ÿšฉ: DynamicProgramming์„ ํ•™์Šตํ•˜๊ณ  ์ •๋ฆฌ * ๐Ÿšฉ: ์ •๋ฆฌํ•œ ๊ธ€์˜ ํŒŒ์ผ๋ช… ๋ณ€๊ฒฝ * ๐Ÿšฉ: ๊ณต๋ถ€ ์ •๋ฆฌ ๊ธ€์„ ์œ„ํ•œ ํ…œํ”Œ๋ฆฟ ์ƒ์„ฑ * ๐Ÿšฉ: ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋กœ sort๋ฅผ ํ™œ์šฉํ•ด์„œ ์ •๋ ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•Œ๊ฒ ์œผ๋‚˜, ์ค‘๋ณต๊ฐ’ ์ œ๊ฑฐ์™€ 1์ฐจ์ ์ธ ์ •๋ ฌ ์ดํ›„ ์ •๋ ฌ๋œ ๊ฐ’ ๊ธฐ์ค€์œผ๋กœ ์žฌ์ •๋ ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด์ง€ ๋ชปํ–ˆ์Œ. * ๐Ÿšฉ: ์ค‘๋ณต ์ œ๊ฑฐ๋ฅผ new Set์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•˜๊ณ  localCompare๋ฅผ ์‚ฌ์šฉํ–ˆ์ง€๋งŒ ์ด ์—ญํ• ์ด ์ •ํ™•ํžˆ ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณผ ํ•„์š”๊ฐ€ ์žˆ๋‹ค. * ๐Ÿšฉ: ๋ฐฐ์—ด์„ map์œผ๋กœ ์ˆœํšŒํ•ด์„œ stack์˜ ๊ตฌ์กฐ๋ฅผ ๊ตฌ์„ฑํ•˜๋ ค ํ–ˆ์œผ๋‚˜ index ๊ฐ’์„ ์›ํ•˜๋Š” ๋ฐ๋กœ ์ปจํŠธ๋กคํ•˜๊ธฐ์— ์–ด๋ ค์›€์ด ์žˆ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด๋Š” ๋ฐฉ์‹์„ ์ข€ ๋” ๊ฐ„๋‹จํ•˜๊ฒŒ ์ƒ๊ฐํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค. ๋„ˆ๋ฌด stack์—๋งŒ ์ง‘์ค‘ํ–ˆ๋‹ค. * ๐Ÿšฉ: ๊ตฌ์กฐ๋ถ„ํ•ด ํ• ๋‹น์„ ๊ฐ„์†Œํ™”ํ•œ ๊ตฌ์กฐ๋กœ ํ™œ์šฉ๊ณผ ์‚ฌ์šฉ์„ ํ•ด๋ณด์•˜๋‹ค. * ๐Ÿ”ง: testํ•˜๊ธฐ ์œ„ํ•œ ์Šคํฌ๋ฆฝํŠธ์™€ ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑ * ๐Ÿšฉ: ์ฝ”๋“œ ๋ถ„์„ ๋ฐ ์ •๋ฆฌ * ๐Ÿ”€: 16173 (#47) * ๐ŸŒฑ: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋…์„ ์œ„ํ•œ issue templates ์ƒ์„ฑ ํ•ด๋‹น ์ฝ”๋“œ๋Š” Github์—์„œ ์ง์ ‘ ์ˆ˜์ • * ๐ŸŒฑ: main ๋ธŒ๋ Œ์น˜ ํ™˜๊ฒฝ ์ดˆ๊ธฐ ์„ธํŒ…์„ ์œ„ํ•œ ์ปค๋ฐ‹ * ๐ŸŒฑ: README์„ ์ˆ˜์ • GitHub์—์„œ ์ง์ ‘ ์ˆ˜์ •ํ•œ issue ์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: printer.js ํŒŒ์ผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: PRํ…œํ”Œ๋ฆฟ์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: PR-TEMPLATE๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: issue templates ์ˆ˜์ • Github์—์„œ ์ž‘์„ฑ๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •๋œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋กœ sort๋ฅผ ํ™œ์šฉํ•ด์„œ ์ •๋ ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•Œ๊ฒ ์œผ๋‚˜, ์ค‘๋ณต๊ฐ’ ์ œ๊ฑฐ์™€ 1์ฐจ์ ์ธ ์ •๋ ฌ ์ดํ›„ ์ •๋ ฌ๋œ ๊ฐ’ ๊ธฐ์ค€์œผ๋กœ ์žฌ์ •๋ ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด์ง€ ๋ชปํ–ˆ์Œ. * ๐Ÿšฉ: ์ค‘๋ณต ์ œ๊ฑฐ๋ฅผ new Set์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•˜๊ณ  localCompare๋ฅผ ์‚ฌ์šฉํ–ˆ์ง€๋งŒ ์ด ์—ญํ• ์ด ์ •ํ™•ํžˆ ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณผ ํ•„์š”๊ฐ€ ์žˆ๋‹ค. * ๐Ÿšฉ: ๋ฐฐ์—ด์„ map์œผ๋กœ ์ˆœํšŒํ•ด์„œ stack์˜ ๊ตฌ์กฐ๋ฅผ ๊ตฌ์„ฑํ•˜๋ ค ํ–ˆ์œผ๋‚˜ index ๊ฐ’์„ ์›ํ•˜๋Š” ๋ฐ๋กœ ์ปจํŠธ๋กคํ•˜๊ธฐ์— ์–ด๋ ค์›€์ด ์žˆ๋‹ค. * ๐Ÿšฉ: ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋‚ด๋Š” ๋ฐฉ์‹์„ ์ข€ ๋” ๊ฐ„๋‹จํ•˜๊ฒŒ ์ƒ๊ฐํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค. ๋„ˆ๋ฌด stack์—๋งŒ ์ง‘์ค‘ํ–ˆ๋‹ค. * ๐ŸŒฑ: stdin์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: printer.js๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: printer.js๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: test.js๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: test.js๋ฅผ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. --- .../manager/algorithm/README-template.md | 35 +++++++++++++ javascript/manager/algorithm/README.md | 50 +++++++++++++++++++ javascript/manager/algorithm/data/data.js | 0 .../manager/algorithm/dynamicProgramming.js | 0 javascript/source/dev/stdin | 2 +- javascript/source/test.js | 2 + javascript/source/test/boolean.js | 5 ++ javascript/source/test/test.js | 3 ++ package.json | 3 +- 9 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 javascript/manager/algorithm/README-template.md create mode 100644 javascript/manager/algorithm/README.md create mode 100644 javascript/manager/algorithm/data/data.js create mode 100644 javascript/manager/algorithm/dynamicProgramming.js create mode 100644 javascript/source/test.js create mode 100644 javascript/source/test/boolean.js create mode 100644 javascript/source/test/test.js diff --git a/javascript/manager/algorithm/README-template.md b/javascript/manager/algorithm/README-template.md new file mode 100644 index 0000000..3c842c4 --- /dev/null +++ b/javascript/manager/algorithm/README-template.md @@ -0,0 +1,35 @@ +# ๐Ÿง AlgorithmType + +> Descriptions + +- ### ๐Ÿงฉ๊ฐœ๋… + - Descriptions +- ### ๐Ÿ‘€ํŠน์ง• + - Descriptions. + +--- + +# ๐Ÿ“Œํ•ต์‹ฌ ์ด๋ก  + +- Descriptions + - Descriptions + +--- + +# ๐Ÿ“๋ฌธ์ œ์˜ˆ์‹œ + +> - Descriptions + +- Descriptions [[๋งํฌ]("ํ’€์ด๋ฐฉ์‹")] + +# โœํ’€์ด๋ฐฉ์‹ + +1. Descriptions + +--- + +# ๐Ÿ‘จโ€๐Ÿ’ปSummary + +> ### ๐Ÿ”ฅKeyWord +> +> - Descriptions diff --git a/javascript/manager/algorithm/README.md b/javascript/manager/algorithm/README.md new file mode 100644 index 0000000..638cbbb --- /dev/null +++ b/javascript/manager/algorithm/README.md @@ -0,0 +1,50 @@ +# ๐Ÿง DynamicProgramming (A.K.A DP) + +> DynamicProgramming, DP, ๋™์  ๊ณ„ํš๋ฒ• + +- ### ๐Ÿงฉ๊ฐœ๋… + - ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ๋ถ€๋ถ„์˜ ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•จ์œผ๋กœ์จ ์ตœ์ข…์ ์œผ๋กœ ๋ณต์žกํ•œ ๋ฌธ์ œ์˜ ๋‹ต์„ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋œปํ•œ๋‹ค. +- ### ๐Ÿ‘€ํŠน์ง• + - ์ž์ฃผ ๋‚˜์˜ค๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ์ด๋ฉฐ ๋ฒ”์œ„๊ฐ€ ์›Œ๋‚™ ๋„“๋‹ค. + +--- + +# ๐Ÿ“Œํ•ต์‹ฌ ์ด๋ก  + +- ํฐ ๋ฌธ์ œ๋ฅผ ์ž‘์€ ๋ฌธ์ œ๋กœ ๋‚˜๋ˆ ์•ผํ•œ๋‹ค. + - ์ ํ™”์‹(์žฌ๊ท€์‹)์œผ๋กœ ํ’€์–ด๋‚ผ ์ˆ˜ ์žˆ๋‹ค. +- ์ž‘์€ ๋ฌธ์ œ๋“ค์ด ๋ฐ˜๋ณต๋ผ ๋‚˜ํƒ€๋‚˜๊ณ  ์‚ฌ์šฉ๋˜๋ฉฐ ์ž‘์€ ๋ฌธ๋„ค๋“ค์˜ ๊ฒฐ๊ด๊ฐ’์€ ํ•ญ์ƒ ๊ฐ™์•„์•ผ ํ•œ๋‹ค. [[๋งํฌ](https://ko.wikipedia.org/wiki/%EC%A0%90%ED%99%94%EC%8B%9D "์ ํ™”์‹ wiki")] +- ์ž‘์€ ๋ฌธ์ œ๋“ค์€ ํ•œ ๋ฒˆ๋งŒ ๊ณ„์‚ฐ(ํ•จ์ˆ˜)ํ•ด์„œ returnํ•ด์•ผ ํ•œ๋‹ค. DPํ…Œ์ด๋ธ”์„ ์ด์šฉํ•œ๋‹ค. ์ด๋ฅผ **๋ฉ”๋ชจ์ด์ œ์ด์…˜** ๊ธฐ๋ฒ• ์ด๋ผ๊ณ  ํ•œ๋‹ค. + - ์‹œ๊ฐ„๋ณต์žก๋„ ์ธก๋ฉด์—์„œ ์œ ๋ฆฌํ•˜๋‹ค. + - **๋ฉ”๋ชจ์ด์ œ์ด์…˜**์€ **๋ฐฑํŠธ๋ž˜ํ‚น** ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ์œ ์‚ฌํ•˜๋‹ค. +- DP๋Š” **ํ†ฑ-๋‹ค์šด** ๋ฐฉ์‹๊ณผ **๋ฐ”ํ…€-์—…** ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ ํ•  ์ˆ˜ ์žˆ๋‹ค. + +--- + +# ๐Ÿ“๋ฌธ์ œ์˜ˆ์‹œ + +> - ๋Œ€ํ‘œ์ ์ธ DP๊ฐ€ ์ ์šฉ๋˜๋Š” ์‚ฌ๋ก€ : ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด ๊ณต์‹ +> - ๊ณต์‹: D[N] = D[N - 1] + D[N - 2] +> - baekjoon: [2747](https://www.acmicpc.net/problem/2747 "2747 baekjoon") + +- ๋ฌธ์ œ: ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด๋กœ `[1,x,2,y,5,z]` ์ด๋ฃจ์–ด์ง„ ๋ฐฐ์—ด x,y,z๋ฅผ ๊ตฌํ•˜์‹œ์˜ค. [[๋งํฌ]("ํ’€์ด๋ฐฉ์‹")] + +# โœํ’€์ด๋ฐฉ์‹ + +1. DP๋กœ ํ’€์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ +2. ์ ํ™”์‹ ์„ธ์šฐ๊ธฐ + > ๋…ผ๋ฆฌ์ ์œผ๋กœ ๋ฌธ์ œ๋ฅผ ๋‚˜๋ˆ„๊ณ , ๋ฌธ์ œ๊ฐ„์˜ **์ธ๊ณผ ๊ด€๊ณ„**๋ฅผ ํŒŒ์•…ํ•˜๋Š” ํ›ˆ๋ จ์ด ํ•„์š”ํ•˜๋‹ค. [[section9 ์กฐํ•ฉ](https://www.inflearn.com/course/lecture?courseSlug=%EB%91%90%EC%9E%87-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-%EC%BD%94%EB%94%A9%ED%85%8C%EC%8A%A4%ED%8A%B8-%ED%8C%8C%EC%9D%B4%EC%8D%AC&unitId=148402&tab=curriculum "inflean")] +3. ๋ฉ”๋ชจ์ œ์ด์…˜ ์›๋ฆฌ ์ดํ•ดํ•˜๊ธฐ + > DPํ…Œ์ด๋ธ”์— ์ €์žฅํ•ด ๋†“๋Š”๋‹ค. +4. ํ†ฑ-๋‹ค์šด ๊ตฌํ˜„ ๋ฐฉ์‹ ์ดํ•ดํ•˜๊ธฐ + > ์œ„์—์„œ๋ถ€ํ„ฐ ๋ฌธ์ œ๋ฅผ ํŒŒ์•…ํ•ด ๋‚ด๋ ค์˜ค๋Š” ๋ฐฉ์‹, ์žฌ๊ท€ํ•จ์ˆ˜ ํ˜•ํƒœ๋กœ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ ๋‹จ, ํƒ‘๋‹ค์šด ๋ฐฉ์‹์€ ์žฌ๊ท€ ํ•จ์ˆ˜์˜ ํ˜•ํƒœ๋กœ ๊ตฌํ˜„ ๋˜๊ธฐ์— **์žฌ๊ท€**์˜ ๊นŠ์ด๊ฐ€ ๋งค์šฐ ๊ธธ์–ด์งˆ ๊ฒฝ์šฐ **๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ**๊ฐ€ ๋ฐœ์ƒ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿด ๊ฒฝ์šฐ **๋ฐ”ํ„ด-์—…์œผ๋กœ ๊ตฌํ˜„, ์ตœ์ ํ™” ํ•„์ˆ˜** + +--- + +# ๐Ÿ‘จโ€๐Ÿ’ปSummary + +> ### ๐Ÿ”ฅKeyWord +> +> - ์ ํ™”์‹ +> - ํ†ฑ-๋‹ค์šด, ๋ฐ”ํ…€-์—… +> - ํ’€์ด๋ฐฉ์‹ diff --git a/javascript/manager/algorithm/data/data.js b/javascript/manager/algorithm/data/data.js new file mode 100644 index 0000000..e69de29 diff --git a/javascript/manager/algorithm/dynamicProgramming.js b/javascript/manager/algorithm/dynamicProgramming.js new file mode 100644 index 0000000..e69de29 diff --git a/javascript/source/dev/stdin b/javascript/source/dev/stdin index b45ef6f..8ab686e 100644 --- a/javascript/source/dev/stdin +++ b/javascript/source/dev/stdin @@ -1 +1 @@ -Hello, World! \ No newline at end of file +Hello, World! diff --git a/javascript/source/test.js b/javascript/source/test.js new file mode 100644 index 0000000..102728c --- /dev/null +++ b/javascript/source/test.js @@ -0,0 +1,2 @@ +const test = require('./test/test'); +const boolean = require('./test/boolean'); diff --git a/javascript/source/test/boolean.js b/javascript/source/test/boolean.js new file mode 100644 index 0000000..acfb29b --- /dev/null +++ b/javascript/source/test/boolean.js @@ -0,0 +1,5 @@ +let check = true; +if (!check) { + console.log('false'); + check = true; +} \ No newline at end of file diff --git a/javascript/source/test/test.js b/javascript/source/test/test.js new file mode 100644 index 0000000..4e73f91 --- /dev/null +++ b/javascript/source/test/test.js @@ -0,0 +1,3 @@ +console.log(test); + +// module.exports = console.log(test); diff --git a/package.json b/package.json index 70216c9..4d7536d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "your-project-name", "version": "1.0.0", "scripts": { - "dev": "node javascript/source/printer.js" + "dev": "node javascript/source/printer.js", + "devtest": "node javascript/source/test.js" }, "author": "Your Name", "license": "ISC", From 9521133e2ab18009a93c0cb8e3074b26a189a162 Mon Sep 17 00:00:00 2001 From: 4Bee <109135643+4BFC@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:29:06 +0900 Subject: [PATCH 02/16] =?UTF-8?q?=F0=9F=8C=B1:=20=20test.js=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. --- javascript/source/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/source/test/test.js b/javascript/source/test/test.js index 4e73f91..d10cff1 100644 --- a/javascript/source/test/test.js +++ b/javascript/source/test/test.js @@ -1,3 +1,3 @@ -console.log(test); +console.log('test'); // module.exports = console.log(test); From 1cce0ad312b46b6dbbab1dac3af66e18e4d58cf3 Mon Sep 17 00:00:00 2001 From: 4Bee <109135643+4BFC@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:29:43 +0900 Subject: [PATCH 03/16] =?UTF-8?q?=F0=9F=8C=B1:=20=20boolean.js=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. --- javascript/source/test/boolean.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/source/test/boolean.js b/javascript/source/test/boolean.js index acfb29b..7ec4800 100644 --- a/javascript/source/test/boolean.js +++ b/javascript/source/test/boolean.js @@ -1,5 +1,5 @@ -let check = true; +let check = false; if (!check) { console.log('false'); check = true; -} \ No newline at end of file +} From 2b8a03c1d5fde08db5ecb717d4e76737f2fdc28a Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Wed, 11 Sep 2024 18:45:57 +0900 Subject: [PATCH 04/16] =?UTF-8?q?=F0=9F=9A=A9:=20reverse=EB=A5=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20shf?= =?UTF-8?q?it=EB=A1=9C=20=EC=95=9E=EC=97=90=EC=84=9C=20=EB=B6=80=ED=84=B0?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0=ED=95=98=EB=A9=B4=EC=84=9C=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/dev/stdin | 3 ++- javascript/source/printer.js | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/javascript/source/dev/stdin b/javascript/source/dev/stdin index 8ab686e..960b298 100644 --- a/javascript/source/dev/stdin +++ b/javascript/source/dev/stdin @@ -1 +1,2 @@ -Hello, World! +4 +3 5 2 7 \ No newline at end of file diff --git a/javascript/source/printer.js b/javascript/source/printer.js index ecb7c5b..f775ce1 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -1,6 +1,27 @@ let path = require('path'); let inputPath = path.join(__dirname, '/dev/stdin'); // __dirname์€ ํ˜„์žฌ ์Šคํฌ๋ฆฝํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ์ ˆ๋Œ€๊ฒฝ๋กœ -let input = require('fs').readFileSync(inputPath).toString().trim().split('\r\n'); +let input = require('fs').readFileSync(inputPath).toString().trim().split('\n'); //'\r\n' //let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); //๋ฐฑ์ค€ ์ œ์ถœ -console.log('Hello, World!'); +let N = input.shift(); +let arr = input[0].split(' ').map(el => +el); +// arr.reverse(); +console.log(arr); +// let compare = arr.reverse(); +// console.log(compare); +let NGE; +let temp = []; +let i = 0; +while (arr.length > 0) { //arr.length > 0 ์ด๋ ‡๊ฒŒ ๋˜๋ฉด ์•ˆ๋˜๋Š” ์ด์œ  + // NGE = arr.pop(); //๋’ค์—์„œ ๋ถ€ํ„ฐ pop์ด๋˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ ๋”ฐ๋ผ, reverse ํ•ด์•ผํ•จ + if (arr[i] < arr[i + 1]) { + console.log(arr[0]); + NGE = arr[i + 1]; + temp.push(NGE); + } else { + temp.push(-1); + } + i++; + arr.shift(); +} +console.log(temp); \ No newline at end of file From 2400042103792746f6a99e431bad35633e57cb60 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Wed, 11 Sep 2024 20:21:57 +0900 Subject: [PATCH 05/16] =?UTF-8?q?=F0=9F=9A=A9:=20=EA=B2=B0=EA=B3=BC=20?= =?UTF-8?q?=EA=B0=92=EC=9D=84=20=EC=A0=80=EC=9E=A5=ED=95=98=EB=8A=94=20tem?= =?UTF-8?q?p=20=EB=B3=80=EC=88=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index f775ce1..730fc62 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -12,7 +12,7 @@ console.log(arr); let NGE; let temp = []; let i = 0; -while (arr.length > 0) { //arr.length > 0 ์ด๋ ‡๊ฒŒ ๋˜๋ฉด ์•ˆ๋˜๋Š” ์ด์œ  +while (arr.length > 0) { // NGE = arr.pop(); //๋’ค์—์„œ ๋ถ€ํ„ฐ pop์ด๋˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ ๋”ฐ๋ผ, reverse ํ•ด์•ผํ•จ if (arr[i] < arr[i + 1]) { console.log(arr[0]); From 0d95268ba625a2fe23c74b0f0528af7465b25284 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Wed, 11 Sep 2024 20:33:26 +0900 Subject: [PATCH 06/16] =?UTF-8?q?=F0=9F=9A=A9:=20=EC=95=9E=20=EB=92=A4?= =?UTF-8?q?=EB=A5=BC=20=EB=B9=84=EA=B5=90=ED=95=98=EB=8A=94=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=8A=94=20=EA=B5=AC=ED=98=84=EC=9D=B4=20=EB=90=98?= =?UTF-8?q?=EC=97=88=EC=9C=BC=EB=82=98=20=EC=9D=B4=EB=AF=B8=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=EA=B0=80=20=EB=90=9C=20=EA=B0=92=EC=9D=80=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B2=8C=20=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=EC=9D=B4=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 730fc62..948435f 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -12,16 +12,20 @@ console.log(arr); let NGE; let temp = []; let i = 0; -while (arr.length > 0) { +while (i < arr.length) { // NGE = arr.pop(); //๋’ค์—์„œ ๋ถ€ํ„ฐ pop์ด๋˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ ๋”ฐ๋ผ, reverse ํ•ด์•ผํ•จ - if (arr[i] < arr[i + 1]) { - console.log(arr[0]); - NGE = arr[i + 1]; - temp.push(NGE); - } else { - temp.push(-1); + // let current = arr.shift(); // ์ฒซ ๋ฒˆ์งธ ๊ฐ’์„ ๊บผ๋‚ด๊ณ  ๋ฐฐ์—ด์—์„œ ์ œ๊ฑฐ + let found = false; + for (let j = 0; j < arr.length; j++) { + //๋น„๊ตํ•œ ๊ฐ’์€ ๋‹ค์‹œ ๋น„๊ต๊ฐ€ ๋˜์ง€ ์•Š๊ฒŒ shift๊ฐ€ ๋˜๋ฉด์„œ ์‚ฌ๋ผ์ ธ์•ผํ•จ. + if (arr[i] < arr[j]) { + NGE = arr[j]; + temp.push(NGE); + found = true; + break; + } } + if (!found) temp.push(-1); i++; - arr.shift(); } console.log(temp); \ No newline at end of file From 755ccbd894bcd443ac419ddae0fcca1aaca9f08f Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Wed, 11 Sep 2024 23:10:33 +0900 Subject: [PATCH 07/16] =?UTF-8?q?=F0=9F=9A=A9:=20if=EB=AC=B8=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=ED=95=B4=EB=B4=A4=EC=A7=80=EB=A7=8C=20?= =?UTF-8?q?=ED=81=B0=EC=88=98=EB=A5=BC=20=EB=B9=84=EA=B5=90=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=EC=9D=B4=20=ED=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=A6=89,=20for=EB=AC=B8=EC=9D=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=B4=EC=95=BC=EB=A7=8C=20=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 948435f..f8bd758 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -6,26 +6,25 @@ let input = require('fs').readFileSync(inputPath).toString().trim().split('\n'); let N = input.shift(); let arr = input[0].split(' ').map(el => +el); // arr.reverse(); -console.log(arr); +// console.log(arr); // let compare = arr.reverse(); // console.log(compare); -let NGE; +// let NGE; let temp = []; -let i = 0; -while (i < arr.length) { - // NGE = arr.pop(); //๋’ค์—์„œ ๋ถ€ํ„ฐ pop์ด๋˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ ๋”ฐ๋ผ, reverse ํ•ด์•ผํ•จ - // let current = arr.shift(); // ์ฒซ ๋ฒˆ์งธ ๊ฐ’์„ ๊บผ๋‚ด๊ณ  ๋ฐฐ์—ด์—์„œ ์ œ๊ฑฐ - let found = false; - for (let j = 0; j < arr.length; j++) { - //๋น„๊ตํ•œ ๊ฐ’์€ ๋‹ค์‹œ ๋น„๊ต๊ฐ€ ๋˜์ง€ ์•Š๊ฒŒ shift๊ฐ€ ๋˜๋ฉด์„œ ์‚ฌ๋ผ์ ธ์•ผํ•จ. - if (arr[i] < arr[j]) { - NGE = arr[j]; - temp.push(NGE); - found = true; - break; - } + +while (arr.length > 0) { + //๊ฒ€์‚ฌํ•œ ๊ฐ’์€ ํ•ญ์‹œ ์‚ญ์ œ + if (arr.length === 1) { + temp.push(-1); + break; + } + let current = arr.shift(); //์‚ญ์ œ๋œ ํ˜„์žฌ ๊ฐ’( = NGE) + + if (current < arr[0]) { + temp.push(arr[0]); + console.log(arr[0]); + } else { + temp.push(-1); } - if (!found) temp.push(-1); - i++; } console.log(temp); \ No newline at end of file From 8c65baf18d7cda24aefab2cd7995aec70fc23df3 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Wed, 11 Sep 2024 23:11:56 +0900 Subject: [PATCH 08/16] =?UTF-8?q?=F0=9F=9A=A9:=20for=EB=AC=B8=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=ED=81=B0=20=EC=88=98=EB=A5=BC=20=EB=B9=84=EA=B5=90?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index f8bd758..438d450 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -11,20 +11,17 @@ let arr = input[0].split(' ').map(el => +el); // console.log(compare); // let NGE; let temp = []; +let stack = []; -while (arr.length > 0) { - //๊ฒ€์‚ฌํ•œ ๊ฐ’์€ ํ•ญ์‹œ ์‚ญ์ œ - if (arr.length === 1) { - temp.push(-1); - break; +for (let i = 0; i < N; i++) { + while (stack.length && arr[stack[stack.length - 1]] < arr[i]) { + temp[stack.pop()] = arr[i]; } - let current = arr.shift(); //์‚ญ์ œ๋œ ํ˜„์žฌ ๊ฐ’( = NGE) + stack.push(i); +} - if (current < arr[0]) { - temp.push(arr[0]); - console.log(arr[0]); - } else { - temp.push(-1); - } +while (stack.length) { + temp[stack.pop()] = -1; } -console.log(temp); \ No newline at end of file + +console.log(temp.join(' ')); \ No newline at end of file From b51f5e2aa7e6636b5727a061989487eb72de4e31 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Thu, 12 Sep 2024 12:40:00 +0900 Subject: [PATCH 09/16] =?UTF-8?q?=F0=9F=9A=A9:=20stack=EC=9D=98=20pop?= =?UTF-8?q?=EC=9D=B4=20=EB=B0=98=ED=99=98=EB=90=98=EB=8A=94=20=EA=B0=92?= =?UTF-8?q?=EC=9D=84=20=ED=99=95=EC=9D=B8=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20test=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/test.js | 2 +- javascript/source/test/stack.js | 37 +++++++++++++++++++++++++++++++++ javascript/source/test/test.js | 3 --- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 javascript/source/test/stack.js delete mode 100644 javascript/source/test/test.js diff --git a/javascript/source/test.js b/javascript/source/test.js index 102728c..de9396e 100644 --- a/javascript/source/test.js +++ b/javascript/source/test.js @@ -1,2 +1,2 @@ -const test = require('./test/test'); +const test = require('./test/stack'); const boolean = require('./test/boolean'); diff --git a/javascript/source/test/stack.js b/javascript/source/test/stack.js new file mode 100644 index 0000000..b07f138 --- /dev/null +++ b/javascript/source/test/stack.js @@ -0,0 +1,37 @@ +console.log('์Šคํƒ ์ดˆ๊ธฐํ™” ๋ฐ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”'); + +// ๊ธฐ๋ณธ ๋ฐฐ์—ด๊ณผ ์Šคํƒ ๋ฐฐ์—ด ์„ ์–ธ +let arr = ['apple', 'banana', 'cherry', 'date', 'fig']; +let stack = [0, 2, 4]; // arr์˜ ์ธ๋ฑ์Šค๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์Šคํƒ +let temp = stack[stack.length - 1]; +console.log('temp: ', temp); +console.log('arr: ', arr[temp]); +// stack์„ ์ด์šฉํ•˜์—ฌ arr์˜ ๊ฐ’์„ ์ถœ๋ ฅ +console.log("์ดˆ๊ธฐ arr:", arr); +console.log("์ดˆ๊ธฐ stack:", stack); + +// ์Šคํƒ์„ ์ด์šฉํ•ด arr์˜ ๊ฐ’์— ์ ‘๊ทผ +console.log("stack์„ ์ด์šฉํ•œ ์ ‘๊ทผ:"); +stack.forEach(index => { + console.log(arr[index]); // stack์˜ ์ธ๋ฑ์Šค๋ฅผ ์ด์šฉํ•ด arr ๊ฐ’ ์ถœ๋ ฅ +}); + +// stack์„ ์ด์šฉํ•ด arr์˜ ๊ฐ’์„ ์ˆ˜์ • (์˜ˆ๋ฅผ ๋“ค์–ด, cherry์™€ fig๋ฅผ ๊ฐ๊ฐ 'grape'์™€ 'kiwi'๋กœ ๋ฐ”๊ฟˆ) +console.log("\nstack์„ ์ด์šฉํ•ด arr์˜ ๊ฐ’ ๋ณ€๊ฒฝ:"); +arr[stack[1]] = 'grape'; // stack[1]์€ 2์ด๋ฏ€๋กœ arr[2] = 'grape' +arr[stack[2]] = 'kiwi'; // stack[2]๋Š” 4์ด๋ฏ€๋กœ arr[4] = 'kiwi' + +// ๋ณ€๊ฒฝ๋œ arr ํ™•์ธ +console.log("๋ณ€๊ฒฝ๋œ arr:", arr); + +// stack์„ ์ด์šฉํ•ด ๋งˆ์ง€๋ง‰ ์š”์†Œ popํ•˜๊ณ , ๊ทธ ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ arr ์ˆ˜์ • +console.log("\nstack์„ popํ•˜์—ฌ arr์˜ ๊ฐ’์„ ์ˆ˜์ •:"); +let lastIndex = stack.pop(); // stack์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค pop +console.log(lastIndex); +arr[lastIndex] = 'mango'; // arr[4] = 'mango'๋กœ ๋ณ€๊ฒฝ + +console.log("pop ํ›„ ๋ณ€๊ฒฝ๋œ arr:", arr); +console.log("pop ํ›„ stack:", stack); + + +// module.exports = console.log(test); diff --git a/javascript/source/test/test.js b/javascript/source/test/test.js deleted file mode 100644 index d10cff1..0000000 --- a/javascript/source/test/test.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log('test'); - -// module.exports = console.log(test); From ea7a3b88edc4b6aecd432df0b78bc83a76118a7c Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Thu, 12 Sep 2024 12:40:27 +0900 Subject: [PATCH 10/16] =?UTF-8?q?=F0=9F=9A=A9:=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EC=9D=98=20=EA=B0=81=20=EC=84=B8=EB=B6=80?= =?UTF-8?q?=EC=A0=81=EC=9D=B8=20=EC=84=A4=EB=AA=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 438d450..8d9a9e5 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -11,13 +11,15 @@ let arr = input[0].split(' ').map(el => +el); // console.log(compare); // let NGE; let temp = []; -let stack = []; - +let stack = []; //index ์ •๋ณด ๋”ฐ๋ผ์„œ arr[i]๋ณด๋‹ค ๋Šฆ๊ฒŒ ๋™์ž‘ํ•ด์•ผํ•จ. for (let i = 0; i < N; i++) { + //&& arr[stack[stack.length - 1] -> ์ดˆ๊ธฐ๊ฐ’ stack ๋ณ€์ˆ˜๋ฅผ index ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” + // = let topIndex = stack[stack.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ + //๊ฒฐ๋ก : stack[stack.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. while (stack.length && arr[stack[stack.length - 1]] < arr[i]) { - temp[stack.pop()] = arr[i]; + temp[stack.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. } - stack.push(i); + stack.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด } while (stack.length) { From 47fd847d5a3dd2652a92d3b197dad6408af5087a Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Thu, 12 Sep 2024 12:41:52 +0900 Subject: [PATCH 11/16] =?UTF-8?q?=F0=9F=9A=A9:=20stack=EC=9D=B4=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=ED=95=98=EB=8A=94=20=EB=B0=A9=EC=8B=9D?= =?UTF-8?q?=EA=B3=BC=20DFS=EB=A5=BC=20=EC=9D=B4=ED=95=B4=ED=95=98=EA=B8=B0?= =?UTF-8?q?=20=EC=9C=84=ED=95=9C=20=EC=82=AC=EA=B3=A0=20=EB=B0=A9=EC=8B=9D?= =?UTF-8?q?=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 8d9a9e5..3b85ae9 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -21,7 +21,7 @@ for (let i = 0; i < N; i++) { } stack.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด } - +//๊ฒฐ๋ก ์ ์œผ๋กœ index๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐฐ์—ด๊ณผ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ณธ๋ž˜์˜ ๋ฐฐ์—ด์„ ๊ฐ€์ง€๊ณ  ๋™์ž‘ํ•œ๋‹ค. while (stack.length) { temp[stack.pop()] = -1; } From c9f563ae4919a4f92ad2be64124e8eeb78ff4804 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Thu, 12 Sep 2024 12:49:22 +0900 Subject: [PATCH 12/16] =?UTF-8?q?=F0=9F=9A=A9:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EC=9D=98=20=EC=A0=84=EC=B2=B4=EC=A0=81=20=ED=9D=90=EB=A6=84?= =?UTF-8?q?=EC=9D=98=20=EC=9D=B4=ED=95=B4=EB=A5=BC=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 3b85ae9..9156b68 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -10,20 +10,20 @@ let arr = input[0].split(' ').map(el => +el); // let compare = arr.reverse(); // console.log(compare); // let NGE; -let temp = []; -let stack = []; //index ์ •๋ณด ๋”ฐ๋ผ์„œ arr[i]๋ณด๋‹ค ๋Šฆ๊ฒŒ ๋™์ž‘ํ•ด์•ผํ•จ. +let result = []; +let temp = []; //index ์ •๋ณด ๋”ฐ๋ผ์„œ arr[i]๋ณด๋‹ค ๋Šฆ๊ฒŒ ๋™์ž‘ํ•ด์•ผํ•จ.(= index, stack) for (let i = 0; i < N; i++) { - //&& arr[stack[stack.length - 1] -> ์ดˆ๊ธฐ๊ฐ’ stack ๋ณ€์ˆ˜๋ฅผ index ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” - // = let topIndex = stack[stack.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ - //๊ฒฐ๋ก : stack[stack.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. - while (stack.length && arr[stack[stack.length - 1]] < arr[i]) { - temp[stack.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. + //&& arr[temp[temp.length - 1] -> ์ดˆ๊ธฐ๊ฐ’ temp ๋ณ€์ˆ˜๋ฅผ index ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” + // = let topIndex = temp[temp.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ + //๊ฒฐ๋ก : temp[temp.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. + while (temp.length && arr[temp[temp.length - 1]] < arr[i]) { + result[temp.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. } - stack.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด + temp.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด } //๊ฒฐ๋ก ์ ์œผ๋กœ index๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐฐ์—ด๊ณผ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ณธ๋ž˜์˜ ๋ฐฐ์—ด์„ ๊ฐ€์ง€๊ณ  ๋™์ž‘ํ•œ๋‹ค. -while (stack.length) { - temp[stack.pop()] = -1; +while (temp.length) { + result[temp.pop()] = -1; } -console.log(temp.join(' ')); \ No newline at end of file +console.log(result.join(' ')); \ No newline at end of file From 95ee98a362cef1e0cdbb398bc44bab1e0f29c2e2 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Sun, 15 Sep 2024 20:26:30 +0900 Subject: [PATCH 13/16] =?UTF-8?q?=F0=9F=9A=A9:=20newArray=EC=97=90?= =?UTF-8?q?=EC=84=9C=20fill=EA=B3=BC=20push,=20=EC=9D=BC=EB=B0=98=20?= =?UTF-8?q?=EB=8C=80=EC=9E=85(=3D)=20=EC=82=BD=EC=9E=85=ED=95=98=EB=8A=94?= =?UTF-8?q?=20=EB=B0=A9=EC=8B=9D=EC=9D=98=20=EC=B0=A8=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=95=B4=EB=B3=B4=EC=95=98?= =?UTF-8?q?=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/test.js | 2 ++ javascript/source/test/newArray_insert.js | 8 ++++++++ javascript/source/test/newArray_push.js | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 javascript/source/test/newArray_insert.js create mode 100644 javascript/source/test/newArray_push.js diff --git a/javascript/source/test.js b/javascript/source/test.js index de9396e..e0335c7 100644 --- a/javascript/source/test.js +++ b/javascript/source/test.js @@ -1,2 +1,4 @@ const test = require('./test/stack'); const boolean = require('./test/boolean'); +const newArray_insert = require('./test/newArray_insert'); +const newArray_push = require('./test/newArray_push'); diff --git a/javascript/source/test/newArray_insert.js b/javascript/source/test/newArray_insert.js new file mode 100644 index 0000000..7485538 --- /dev/null +++ b/javascript/source/test/newArray_insert.js @@ -0,0 +1,8 @@ +let arr = new Array(5).fill(0); // ๊ธธ์ด๊ฐ€ 5์ธ ๋ฐฐ์—ด์„ 0์œผ๋กœ ์ฑ„์›€ + +console.log(arr); // [0, 0, 0, 0, 0] + +arr[3] = 5; //[ 0, 0, 0, 5, 0 ] +//ํŠน์ • ๊ฐ’์„ ์ง€์ •ํ•ด์„œ ๋ณ€๊ฒฝ + +console.log(arr); \ No newline at end of file diff --git a/javascript/source/test/newArray_push.js b/javascript/source/test/newArray_push.js new file mode 100644 index 0000000..63edd44 --- /dev/null +++ b/javascript/source/test/newArray_push.js @@ -0,0 +1,8 @@ +let arr = new Array(5).fill().map(() => []); // ๊ธธ์ด๊ฐ€ 5์ธ ๋ฐฐ์—ด์„ ๋นˆ ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” +// = `let arr = new Array(5).fill([]);` ์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹ +console.log(arr); // [[], [], [], [], []] + +arr[3].push(5); //[ [], [], [], [ 5 ], [] ] +// arr[3]์€ ๋นˆ ๋ฐฐ์—ด์ด๋ฏ€๋กœ ์—ฌ๊ธฐ์„œ push๊ฐ€ ๊ฐ€๋Šฅ -> `arr[3] = 5;`๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด 2์ฐจ์› ๋ฐฐ์—ด์„ ์œ ์ง€ํ•˜์ง€ ์•Š๊ณ  ๊ฐ’์„ ๋ณ€๊ฒฝํ•œ๋‹ค. + +console.log(arr); // [[], [], [], [5], []] From fa922b2fbcf275e5309eed567a7e2762667c3891 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Sun, 15 Sep 2024 21:42:43 +0900 Subject: [PATCH 14/16] =?UTF-8?q?=F0=9F=9A=A9:=20temp.push=EA=B0=80=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=ED=95=98=EB=8A=94=20=EC=98=81=EC=97=AD=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=EC=9C=BC=EB=A1=9C=20=ED=91=9C=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 9156b68..2059560 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -17,8 +17,11 @@ for (let i = 0; i < N; i++) { // = let topIndex = temp[temp.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ //๊ฒฐ๋ก : temp[temp.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. while (temp.length && arr[temp[temp.length - 1]] < arr[i]) { + console.log(temp[temp.length - 1]); + console.log(temp); result[temp.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. - } + } //while๋ฌธ ์ค‘๊ด„ํ˜ธ + //for๋ฌธ ์˜์—ญ temp.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด } //๊ฒฐ๋ก ์ ์œผ๋กœ index๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐฐ์—ด๊ณผ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ณธ๋ž˜์˜ ๋ฐฐ์—ด์„ ๊ฐ€์ง€๊ณ  ๋™์ž‘ํ•œ๋‹ค. From 241aed723be34a9f8cedad51a033a11f35615131 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Sun, 15 Sep 2024 21:43:36 +0900 Subject: [PATCH 15/16] =?UTF-8?q?=F0=9F=9A=A9:=20while=EB=AC=B8=20?= =?UTF-8?q?=EC=98=81=EC=97=AD=EC=9D=84=20for=EB=AC=B8=EA=B3=BC=20if?= =?UTF-8?q?=EB=AC=B8=EC=9C=BC=EB=A1=9C=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 2059560..2a77b83 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -16,10 +16,14 @@ for (let i = 0; i < N; i++) { //&& arr[temp[temp.length - 1] -> ์ดˆ๊ธฐ๊ฐ’ temp ๋ณ€์ˆ˜๋ฅผ index ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” // = let topIndex = temp[temp.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ //๊ฒฐ๋ก : temp[temp.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. - while (temp.length && arr[temp[temp.length - 1]] < arr[i]) { - console.log(temp[temp.length - 1]); - console.log(temp); - result[temp.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. + for (let j = temp.length - 1; j >= 0; j--) { + if (arr[temp[j]] < arr[i]) { + console.log(temp[j]); + console.log(temp); + result[temp.pop()] = arr[i]; // stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. + } else { + break; // ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜์ง€ ์•Š์œผ๋ฉด ๋” ์ด์ƒ ํƒ์ƒ‰ํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ค‘๋‹จ + } } //while๋ฌธ ์ค‘๊ด„ํ˜ธ //for๋ฌธ ์˜์—ญ temp.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด From a2219520f549058eced1c0958be3cf4a825baa39 Mon Sep 17 00:00:00 2001 From: 4Bee <4bee.code@gmail.com> Date: Sun, 15 Sep 2024 21:44:58 +0900 Subject: [PATCH 16/16] =?UTF-8?q?=F0=9F=9A=A9:=20while=EB=AC=B8=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=8B=A4=EC=8B=9C=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/source/printer.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/javascript/source/printer.js b/javascript/source/printer.js index 2a77b83..2059560 100644 --- a/javascript/source/printer.js +++ b/javascript/source/printer.js @@ -16,14 +16,10 @@ for (let i = 0; i < N; i++) { //&& arr[temp[temp.length - 1] -> ์ดˆ๊ธฐ๊ฐ’ temp ๋ณ€์ˆ˜๋ฅผ index ๋ฐฐ์—ด๋กœ ์ดˆ๊ธฐํ™” // = let topIndex = temp[temp.length - 1]; // ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ์ถ”์ถœ //๊ฒฐ๋ก : temp[temp.length - 1]๋Š” Number์ด๋‹ค. ์ฆ‰, ์ดˆ๊ธฐ๊ฐ’์€ index 3์ด๋ฉฐ 3์„ ์ฐธ์กฐํ•˜๋Š” ๊ฐ’์€ 7์ด๋‹ค. - for (let j = temp.length - 1; j >= 0; j--) { - if (arr[temp[j]] < arr[i]) { - console.log(temp[j]); - console.log(temp); - result[temp.pop()] = arr[i]; // stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. - } else { - break; // ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜์ง€ ์•Š์œผ๋ฉด ๋” ์ด์ƒ ํƒ์ƒ‰ํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ค‘๋‹จ - } + while (temp.length && arr[temp[temp.length - 1]] < arr[i]) { + console.log(temp[temp.length - 1]); + console.log(temp); + result[temp.pop()] = arr[i]; //stack์—์„œ pop์„ ํ•ด๋„ index ๊ฐ’์ด pop๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ˜ํ™˜๊ฐ’ ์—ญ์‹œ number์ด๋‹ค. } //while๋ฌธ ์ค‘๊ด„ํ˜ธ //for๋ฌธ ์˜์—ญ temp.push(i); //stack์— i๊ฐ€ ๋“ค์–ด๊ฐ ์ด์œ ๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด