์•Œ๊ณ ๋ฆฌ์ฆ˜) Two Pointer, Sliding Window

Two Pointer 2๊ฐœ์˜ ์ง€์ (ํฌ์ธํ„ฐ)์„ ์˜ฎ๊ฒจ๊ฐ€๋ฉฐ ๋‹ต์„ ๊ตฌํ•œ๋‹ค. ์ˆœ์ฐจ์  ์ ‘๊ทผ ๋“ฑ์ด ์š”๊ตฌ๋˜๋Š” ํŠน์ˆ˜ํ•œ ์ƒํ™ฉ์—์„œ ์‚ฌ์šฉ๋œ๋‹ค. ex) ์ •๋ ฌ๋œ ๋‘ ๋ฐฐ์—ด์„ ํ•˜๋‚˜์˜ ์ •๋ ฌ๋œ ๋ฐฐ์—ด๋กœ ํ•ฉ์น  ๋•Œ(Merge Sort์—์„œ ์‚ฌ์šฉ๋จ), ์–ด๋–ค ๋ฐฐ์—ด์˜ ์—ฐ์† ๋ถ€๋ถ„์ง‘ํ•ฉ์˜ ์›์†Œํ•ฉ์ด k์ธ ๊ฒฝ์šฐ๋ฅผ ์ฐพ๋Š” ๊ฒฝ์šฐ ๋“ฑ ... ์ž์„ธํ•œ ๋‚ด์šฉ์€ Merge Sort ๋ถ€๋ถ„ ์ฐธ๊ณ  Sliding Window Two pointer์™€ ๋น„์Šทํ•˜์ง€๋งŒ, ๋‘ ํฌ์ธํ„ฐ ์‚ฌ์ด์˜ ๊ธธ์ด๊ฐ€ ๊ณ ์ •๋˜์–ด์žˆ๋‹ค๋Š” ์ฐจ์ด๊ฐ€ ์žˆ๋‹ค. Input Output ์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ๋ฐฐ์—ด D์˜ ์›์†Œ์˜ ๊ฐœ์ˆ˜ N๊ณผ ์œˆ๋„์šฐ ์‚ฌ์ด์ฆˆ K ๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ๋‘ ๋ฒˆ์งธ ์ค„์—๋Š” ๋ฐฐ์—ด์˜ ์›์†Œ Di๊ฐ€ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. (Di ๋Š” ์ž์—ฐ์ˆ˜) ๋ฐฐ์—ด D์˜ ๊ธธ์ด๊ฐ€ K์ธ ์—ฐ์†๋ถ€๋ถ„์ง‘ํ•ฉ์˜ ์›์†Œ ํ•ฉ์˜ ์ตœ๋Œ€๊ฐ’์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. import java.util...

Algorithm 2019. 9. 12. 19:04
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
๊ธ€ ๋ณด๊ด€ํ•จ