Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ksundong/algorithm-solution

๐Ÿ”ฅ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด
https://github.com/ksundong/algorithm-solution

codingtest leetcode programmers

Last synced: 3 months ago
JSON representation

๐Ÿ”ฅ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด

Awesome Lists containing this project

README

        

# algorithm-solution

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด๋ฅผ ์˜ฌ๋ฆฌ๋Š” ์ €์žฅ์†Œ

## [ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค](https://programmers.co.kr/)

1. [์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/42576)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/incompleteplayer/Solution.java)
2. [๋ฌธ์ž์—ด ์••์ถ•](https://programmers.co.kr/learn/courses/30/lessons/60057)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/compressstring/Solution.java)
- ํ•ด์‹œ๋ฅผ ์‚ฌ์šฉํ•ด๋ด์•ผ ์ด์ ์ด ์—†๋Š” ๋“ฏ ์‹ถ์–ด ํ•ด์‹œ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋‹ค.
3. [K๋ฒˆ์งธ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/42748)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/19427fc431bf5b53fdea06dd4ced059383810885/src/main/java/dev/idion/programmers/kthnumber/Solution.java)
- ๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ quick sort๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์—ˆ๋‹ค.
4. [๊ฐ€์žฅ ํฐ ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/42746)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/biggestnumber/Solution.java)
- String์„ ํ•ฉ์นœ๊ฒƒ์„ ๋น„๊ตํ•˜๋Š” ๊ฒƒ vs ๊ฐ™์€ string์„ 4๋ฒˆ ๋ฐ˜๋ณตํ•œ ํ›„ 4์ž๋ฆฌ๊นŒ์ง€ ์ž๋ฅด๋Š” ๊ฒƒ
- ์˜ˆ์™ธ ์‚ฌํ•ญ์ด ์ข€ ๋งŽ๋‹ค. 0์ด๋‚˜ 12, 121 ๊ฐ™์€๊ฒƒ.
- ์†ŒํŠธ ๋ฉ”์†Œ๋“œ๋ฅผ ํ™œ์šฉํ•˜๋Š” Comparator๋ฅผ ์ž˜ ํ™œ์šฉํ•˜๋ฉด ์ •๋ ฌ๋ฌธ์ œ๋ฅผ ์ข€ ๋” ๋น ๋ฅด๊ฒŒ ํ’€ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
5. [์œ„์žฅ](https://programmers.co.kr/learn/courses/30/lessons/42578)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/camouflage/Solution.java)
- ์ด๋ฆ„์ด ๊ฒน์น˜๋Š” ์˜์ƒ์ด ์—†๋‹ค๋Š” ๊ฒƒ์ด ํžŒํŠธ๊ณ , ๋‘๋ฒˆ์งธ๋Š” ๋ถ€์œ„๋ณ„๋กœ ์•ˆ์ž…๊ฑฐ๋‚˜, ํ•˜๋‚˜๋งŒ ์ž…๊ฑฐ๋‚˜์˜ ๊ฒฝ์šฐ์˜ ์ˆ˜๋ผ๋Š”๊ฒŒ ํžŒํŠธ์˜€๋‹ค.
- ๊ฒฝ์šฐ์˜ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•ด๋ณด๋ฉด ์˜์ƒ์˜ ๊ฐœ์ˆ˜ + 1(์•ˆ์ž…๋Š” ๊ฒฝ์šฐ)๋ฅผ ๊ฐ๊ฐ ๊ณฑํ•ด์ค€ ํ›„, ๋ชจ๋‘ ์•ˆ์ž…๋Š” ๊ฒฝ์šฐ์˜ ์ˆ˜์ธ 1์„ ๋นผ์ฃผ๋ฉด ๋œ๋‹ค.
6. [์ „ํ™”๋ฒˆํ˜ธ ๋ชฉ๋ก](https://programmers.co.kr/learn/courses/30/lessons/42577)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/phonenumberlist/Solution.java)
- ์ด์ค‘ for๋ฌธ์„ ์ด์šฉํ•˜์—ฌ ํ’€์—ˆ๋‹ค.
- ์‚ฌ์ „์— ์ •๋ ฌ์„ ํ•˜๊ณ  ๋’ค์˜ ๊ฒƒ์„ ์•ž์˜ ๊ฒƒ์ด ํฌํ•จ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ–ˆ๋‹ค.(Stringํ˜•ํƒœ๋Š” ์‚ฌ์ „์‹ ์ •๋ ฌ์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—)
- ํ•ด์‹œ๋ฅผ ์ ์šฉํ•œ ํ’€์ด๋ฅผ ๋ณด์•˜๋Š”๋ฐ 2์ค‘ for๋ฌธ, for๋ฌธ ๊ตฌ์กฐ๋กœ ๋” ๋ณต์žกํ•ด์ง€๋Š” ๊ฒฝํ–ฅ์ด ์žˆ์–ด ํ’€์ด์—์„  ์ œ์™ธํ•˜์˜€๋‹ค.
7. [์ฒด์œก๋ณต](https://programmers.co.kr/learn/courses/30/lessons/42862)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/gymsuit/Solution.java)
- ์ผ๋‹จ Test Case๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.
- ์ผ๋‹จ ๋ฐฐ์—ด์˜ length๊ฐ’์„ ๋นผ๊ณ  ๋”ํ•ด๋ณด์•˜๋‹ค. (test 1, 3 ์‹คํŒจ)
- ๋งŒ๋“ค์–ด ๋‘” Test Case๋ฅผ ๋ชจ๋‘ ๋งŒ์กฑํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์˜€๋‹ค.
- ์˜ˆ์™ธ ์ƒํ™ฉ์ด ์žˆ์–ด์„œ(์กฐ๊ฑด์„ ์ œ๋Œ€๋กœ ์•ˆ์ฝ์–ด์„œ) ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ–ˆ๋‹ค. (๋จผ์ € ๊ฐ™์€ ๊ฒฝ์šฐ๋ฅผ ๋น„๊ต)
8. [2016๋…„](https://programmers.co.kr/learn/courses/30/lessons/12901)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/year2016/Solution.java)
- Test Case๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์—ˆ๋‹ค.
- ๋„ˆ๋ฌด ์‰ฌ์› ๋‹ค. ์—ญ์‹œ CodeSquad Java Playground!
- https://www.inflearn.com/course/java-codesquad/dashboard
9. [๊ฐ€์šด๋ฐ ๊ธ€์ž ๊ฐ€์ ธ์˜ค๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12903)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/getmiddlecharacter/Solution.java)
- Test Case๋ฅผ ๊ฐ€์ ธ์™€์„œ ๋งŒ๋“ค์—ˆ๋‹ค.
- ์—ญ์‹œ ๋„ˆ๋ฌด ์‰ฌ์› ๋‹ค.
- ์ข€ ๋” ์งง์€ ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ, ์ง์ˆ˜, ํ™€์ˆ˜ ๋ชจ๋‘ ํ†ต์šฉ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ์งœ๊ธฐ์œ„ํ•ด ๋…ธ๋ ฅํ–ˆ๋‹ค.
10. [๊ฐ™์€ ์ˆซ์ž๋Š” ์‹ซ์–ด](https://programmers.co.kr/learn/courses/30/lessons/12906)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/7229adab2d/src/main/java/dev/idion/programmers/noduplicatenumber/Solution.java)
- ํ’€์ด๋Š” ํ–ˆ์ง€๋งŒ ๊ณต๊ฐ„๋ณต์žก๋„๊ฐ€ ๋†’์•„์ง€๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค.
- Arrays.copyOf๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋”๋‹ˆ 0.5 ms๊ฐ€ ๋‹จ์ถ•๋˜์—ˆ๋‹ค.
11. [๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€๋Š” ์ˆซ์ž ๋ฐฐ์—ด](https://programmers.co.kr/learn/courses/30/lessons/12910)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/dividingnumberarray/Solution.java)
- ๋ณ„๋กœ ๊นŠ๊ฒŒ ์ƒ๊ฐํ•ด๋ณด์ง€ ์•Š์•„๋„ ๋˜๋Š” ๋ฌธ์ œ์˜€๋‹ค.
12. [๋‘ ์ •์ˆ˜ ์‚ฌ์ด์˜ ํ•ฉ](https://programmers.co.kr/learn/courses/30/lessons/12912)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/twointegersum/Solution.java)
- ๋“ฑ์ฐจ์ˆ˜์—ด์˜ ํ•ฉ ๊ณต์‹์„ ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค.
- for๋ฌธ์œผ๋กœ ํ’€๋ฉด ์˜ค๋ž˜๊ฑธ๋ฆผ(ํ†ต๊ณผ๋Š” ํ•จ...)
13. [๋ฌธ์ž์—ด ๋‚ด ๋งˆ์Œ๋Œ€๋กœ ์ •๋ ฌํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12915)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/stringsortmyself/Solution.java)
- ์ข€ ์žฌ๋ฏธ์žˆ์–ด ๋ณด์ด๋Š” ๋ฌธ์ œ๋‹ค.
- comparator๋ฅผ ์ข€ ๋” ์žฌ๋ฐŒ๊ฒŒ ์“ธ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
- ๊ฐ•์ถ”๋ฌธ์ œ!!
14. [๋ฌธ์ž์—ด ๋‚ด p์™€ y์˜ ๊ฐœ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/12916)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/stringpandycount/Solution.java)
- uppercase๋‚˜ lowercase๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์†๋„๊ฐ€ ์–ด๋–ป๊ฒŒ ๋ณ€ํ• ์ง€๋Š” ๊ณ ๋ฏผํ•ด๋ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ๋กœ์ง์€ ๊ฐ„๋‹จ!
15. [๋ฌธ์ž์—ด ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ๋ฐฐ์น˜ํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12917)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/stringdescendingorder/Solution.java)
- ๋žŒ๋‹ค์‹์œผ๋กœ ํ–ˆ๋Š”๋ฐ ๋„ˆ๋ฌด ๋Š๋ฆฐ ๊ฒƒ ๊ฐ™๋‹ค.
- StringBuilder์— reverse ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์ฒ˜์Œ ์•Œ์•˜๋‹ค.
16. [๋ฌธ์ž์—ด ๋‹ค๋ฃจ๊ธฐ ๊ธฐ๋ณธ](https://programmers.co.kr/learn/courses/30/lessons/12918)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/basicstringcontrol/Solution.java)
- ์ฒ˜์Œ์—” Pattern, Matcher๋ฅผ ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋Š”๋ฐ, String์— matches๋ผ๋Š” ๋ฉ”์†Œ๋“œ๊ฐ€ ์ œ๊ณต๋˜์–ด์„œ ์ˆ˜์ •ํ–ˆ๋‹ค.
- ์—„์ฒญ ์งง๊ฒŒ ๋ฐ”๊พธ์—ˆ๋‹ค. ์ •๊ทœ์‹์œผ๋กœ ํ’€๋ฉด ์—„์ฒญ ์งง๋‹ค!
17. [์„œ์šธ์—์„œ ๊น€์„œ๋ฐฉ ์ฐพ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12919)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/kimseobang/Solution.java)
- ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋„ ๋น„์Šทํ•˜๊ฒŒ ํ’€์–ด์„œ... ์ฐธ๊ณ ํ• ๊ฒƒ์ด ์—†์—ˆ๋‹ค.
18. [์†Œ์ˆ˜ ์ฐพ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12921)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/primenumber/Solution.java)
- ์ฒ˜์Œ์—” n^2๋กœ ํ’€์—ˆ๋Š”๋ฐ ์ˆซ์ž ๋ฒ”์œ„๊ฐ€ ๋ฐฑ๋งŒ์ด์–ด์„œ ์†๋„๋ฅผ ๊ฐœ์„ ํ•  ๋ฐฉ๋ฒ•์„ ์ฐพ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค.
- ์ œ๊ณฑ๊ทผ๊นŒ์ง€ loop๋ฅผ ๋Œ๋ฆฐ๋‹ค๋Š” ๋‚ด์šฉ์€ ๊ทธ ์ด์ƒ์€ ์ ˆ๋Œ€ ๋‚˜๋ˆ„์–ด ๋–จ์–ด์งˆ ์ˆ˜ ์—†๋‹ค๋Š” ๋œป์ด์—ˆ์Šต๋‹ˆ๋‹ค.
- ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด๋ผ๋Š” ํ’€์ด ๋ฐฉ์‹๋„ ์žˆ์–ด ์ ์šฉํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.
19. [์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜?](https://programmers.co.kr/learn/courses/30/lessons/12922)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/watermelon/Solution.java)
- ์˜ˆ์ „์— ํ’€์—ˆ๋˜ ๋ฌธ์  ๋ฐ, ๋˜‘๊ฐ™์ด ํ’€์—ˆ๋‹ค..?
- ์ˆ˜๋ฐ•์„ ๋งŒ์ž ์ž…๋ ฅํ•ด์„œ substring์œผ๋กœ ํ‘ผ ์‚ฌ๋žŒ์ด ์žˆ๋˜๋ฐ, ์ •๋ง ๋Œ€๋‹จํ•˜๋‹ค ใ…‹ใ…‹ใ…‹
20. [๋ฌธ์ž์—ด์„ ์ •์ˆ˜๋กœ ๋ฐ”๊พธ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12925)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/parseint/Solution.java)
- ์Œ... ๋ฌธ์ œ์ถœ์ œ์˜๋„๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ, ์ž˜๋ชป์ž…๋ ฅ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์—†๋‹ค๊ณ  ํ•ด์„œ parseInt๋ฅผ ์‚ฌ์šฉํ•˜์˜€๋‹ค.
21. [์‹œ์ € ์•”ํ˜ธ](https://programmers.co.kr/learn/courses/30/lessons/12926)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/caesarcipher/Solution.java)
- char ํ˜•์— ๋Œ€ํ•ด์„œ ๊นŠ๊ฒŒ ์ƒ๊ฐํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
- ๋‚˜์ค‘์— ํ•œ ๋ฒˆ ๋” ํ’€์–ด๋ณด๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.
22. [์•ฝ์ˆ˜์˜ ํ•ฉ](https://programmers.co.kr/learn/courses/30/lessons/12928)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/sumofmeasure/Solution.java)
- ์•ฝ์ˆ˜๋Š” ์ƒ๊ฐํ•ด๋ณด๋‹ˆ 2๋กœ ๋‚˜๋ˆ„๋ฉด ๋” ์ ์€ loop๋ฅผ ๋Œ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
- ๋‚˜์ค‘์— ๋‹ค์‹œ ํ’€์–ด๋ด์•ผ๊ฒ ๋‹ค.
23. [์ด์ƒํ•œ ๋ฌธ์ž ๋งŒ๋“ค๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12930)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/weirdstring/Solution.java)
- ๋ฌธ์ œ์˜ ์กฐ๊ฑด์„ ์ข€ ๋” ์ฝ๋Š” ์Šต๊ด€์„ ๋“ค์—ฌ์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. (์ฒ˜์Œ ์ œ์ถœํ•œ ๊ฑด ๋‹จ์–ด๋‹จ์œ„๋กœ ์„ธ๋Š”๊ฑธ ์•ˆ์ฝ๊ณ  ํ’€์—ˆ๋‹ค.)
- ๊ฐ€๊ธ‰์ ์ด๋ฉด split์„ ์ด์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” character array๋กœ ๊ฐ€๋Šฅํ•œ ๋ฌธ์ œ์˜ ๊ฒฝ์šฐ char array๋ฅผ ์“ฐ๋Š”๊ฒŒ ๋‚˜์€ ๊ฒƒ ๊ฐ™๋‹ค.
24. [์ž๋ฆฟ์ˆ˜ ๋”ํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12931)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/digitplus/Solution.java)
- ํ•จ์ •์ธ ๊ฒฝ์šฐ๋„ ์—†๊ณ , ๊ทธ๋ƒฅ ์ˆซ์ž์˜ ์ž๋ฆฟ์ˆ˜๋ฅผ ์–ด๋–ป๊ฒŒ ๋‹ค๋ฃจ๋Š”์ง€ ์ƒ๊ฐํ•˜๋Š” ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐ๋œ๋‹ค.
25. [์ž์—ฐ์ˆ˜ ๋’ค์ง‘์–ด ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12932https://programmers.co.kr/learn/courses/30/lessons/12932)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/naturalnumberarray/Solution.java)
- ๊ตณ์ด string์œผ๋กœ ๋งŒ๋“ค ํ•„์š”๊ฐ€ ์žˆ๋‚˜ ์‹ถ์–ด์„œ while loop๋ฅผ ๋‘ ๋ฒˆ ์‚ฌ์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค.
26. [์ •์ˆ˜ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ๋ฐฐ์น˜ํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12933)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/integerdesc/Solution.java)
- ๊ธฐ์กด ํ’€์ด๋Š” intํ˜•์œผ๋กœ ๋ฐ›์•„์„œ ์ฐธ๊ณ ํ• ๋งŒํ•œ ๊ฒƒ์ด ์—†์—ˆ๋‹ค.
- Lambda์™€ Stream์„ ์“ฐ๋Š” ํ’€์ด๋Š” ๋ชจ๋ฅด๊ฒ ๋‹ค. ํ•จ์ˆ˜ํ˜•์ด ํ•„์š”ํ•œ ๋ถ€๋ถ„์ธ๊ฐ€ ์‹ถ๋‹ค.
- String์œผ๋กœ ๋ณ€ํ™˜ํ•ด์„œ Long.parseLong์„ ์‚ฌ์šฉํ•˜๋Š” ํ’€์ด๋Š” ์ข‹์€ ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•˜๊ณ ... ์†๋„๋Š” ์ž˜ ๋‚˜์˜ค๋‚˜??
27. [์ •์ˆ˜ ์ œ๊ณฑ๊ทผ ํŒ๋ณ„](https://programmers.co.kr/learn/courses/30/lessons/12934)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/integersquareroot/Solution.java)
- Math.sqrt ์—†์ด ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—†์„๊นŒ? ๊ณ ๋ฏผํ–ˆ๋Š”๋ฐ for loop๋Œ์•„์•ผ ํ•  ๊ฒƒ ๊ฐ™์•„์„œ ๋ณ„๋กœ ํšจ์œจ์ด ์ข‹์ง„ ์•Š์„ ๊ฒƒ ๊ฐ™๋‹ค.
- Math.sqrt๋ฅผ ๊นŒ๋ดค๋Š”๋ฐ, Note that hardware sqrt instructions ๋ผ๊ณ  ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์•„ ์ด๊ฒŒ ์ œ์ผ ํšจ์œจ์ ์ธ ๊ฒƒ ๊ฐ™๋‹ค.
- Math.pow๋ฅผ ์“ฐ๊ธฐ๋ณด๋‹จ ๊ทธ๋ƒฅ ๊ณฑํ•ด์„œ ๋น„๊ต๋ฅผ ํ•ด์ฃผ์—ˆ๋‹ค.
28. [์ œ์ผ ์ž‘์€ ์ˆ˜ ์ œ๊ฑฐํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12935)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/deleteminnum/Solution.java)
- O(n)์œผ๋กœ ํ’€์—ˆ๋‹ค. Stream์„ ์จ์„œ ํ‘ผ ์‚ฌ๋žŒ๋„ ์žˆ์—ˆ๋Š”๋ฐ, ๊ฒฐ๊ตญ ๋Š๋ฆฌ๋”๋ผ...
- ์ตœ์†Œ๊ฐ’์„ ์ฐพ๊ณ , ๊ทธ๊ฒƒ๋งŒ ๋นผ๊ณ  ๋„ฃ์–ด์ฃผ๋Š”๊ฒŒ ๊ฐ€์žฅ ๋น ๋ฅผ ๊ฒƒ ๊ฐ™์€๋ฐ, ๋” ๋น ๋ฅธ ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ?
29. [์ง์ˆ˜์™€ ํ™€์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/12937)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/evenandodd/Solution.java)
- ๊ฐ„๋‹จํ•œ ๋ฌธ์  ๋ฐ, ์ฝ”๋“œ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ๋” ์งง๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€๋„ ๊ณ ๋ฏผํ•ด๋ณด๋Š” ๊ฒŒ ์ข‹์€ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค.
- ์™œ ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋ฅผ ์“ธ ์ƒ๊ฐ์„ ์•ˆํ–ˆ์ง€?
30. [์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/12940)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/gcfandlcm/Solution.java)
- ์žฌ๊ท€๋กœ ํ‘ธ๋Š” ํ’€์ด๋Š” ์ƒ๊ฐํ•˜์ง€ ๋ชปํ–ˆ๋Š”๋ฐ, ์ˆ˜ํ•™์ ์œผ๋กœ ์ƒ๊ฐํ•œ ๊ฒƒ์ธ์ง€ ๊ถ๊ธˆํ–ˆ๋‹ค.
- ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๋ฅผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋กœ ํ‘ธ๋‹ˆ ์ƒ๋‹นํžˆ ๊นŒ๋‹ค๋กญ๋‹ค๊ณ  ๋Š๊ปด์กŒ๋‹ค.
31. [์ฝœ๋ผ์ธ  ์ถ”์ธก](https://programmers.co.kr/learn/courses/30/lessons/12943)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/collatzconjecture/Solution.java)
- ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋ฅผ ์˜๋„์ ์œผ๋กœ ์‚ฌ์šฉํ•ด๋ณด์•˜๋‹ค. if-else์— ๋น„ํ•ด ๊ฐ€๋…์„ฑ์ด ์ข‹์•„์กŒ๋‹ค.
- while Loop๋ƒ for Loop๋ƒ์˜ ๊ด€์  ์ฐจ์ด๋Š” ๋ฌธ์ œ์˜ ์กฐ๊ฑด์„ ์–ด๋–ป๊ฒŒ ํ•ด์„ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ๊ฒƒ ๊ฐ™๋‹ค. ๋‚˜๊ฐ™์€ ๊ฒฝ์šฐ์—” 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ค‘์š”ํ•˜๋‹ค ํŒ๋‹จํ–ˆ๋‹ค.
- ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์นœ์ ˆํ•ด์„œ ์˜ค๋ฅ˜๋ฅผ ์‚ฌ์ „์— ์•Œ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ์ž๋ฃŒํ˜•๋„ ์‹ ๊ฒฝ์จ์•ผํ•จ์„ ์•Œ๋ ค์ฃผ๋‹ˆ๊นŒ ์ข‹์€ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค.
32. [ํ‰๊ท  ๊ตฌํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12944)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/getaverage/Solution.java)
- ๋ณ„๋กœ ์ข‹์ง€ ์•Š์€ ๋ฌธ์ œ
33. [ํ•˜์ƒค๋“œ ์ˆ˜](https://programmers.co.kr/learn/courses/30/lessons/12947)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/harshadnumber/Solution.java)
- ์ˆซ์ž๋ฅผ ํ•œ ์ž๋ฆฌ์”ฉ ๋ถ„๋ฆฌํ•˜๋Š” ๊ธฐ๋ฒ•๋ง๊ณ ๋Š” ๊ทธ๋‹ฅ ์ข‹์ง€์•Š์€ ๋ฌธ์ œ...
34. [ํ•ธ๋“œํฐ ๋ฒˆํ˜ธ ๊ฐ€๋ฆฌ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12948)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/maskingphonenumber/Solution.java)
- ์ •๊ทœ์‹์„ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๋น„ํšจ์œจ์ ์ธ ๊ฒƒ ๊ฐ™์•„์„œ ๊ทธ๋ƒฅ char๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด์„œ ํ’€์—ˆ๋‹ค.
35. [ํ–‰๋ ฌ์˜ ๋ง์…ˆ](https://programmers.co.kr/learn/courses/30/lessons/12950)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/sumofprocession/Solution.java)
- ๋ฌธ์ œ ์กฐ๊ฑด์ด ๋ช…ํ™•ํ•˜์ง€ ์•Š์•„์„œ ๋ณ„๋กœ์˜€๋‹ค.
- ์‹ ๊ธฐํ•œ๊ฑด, length2๋ฅผ ๋ฏธ๋ฆฌ ์„ ์–ธํ•ด ์ฃผ๋Š”๊ฒŒ ๋” ๋Š๋ฆฌ๋‹ค๋Š”์ ... ํŽธ์ฐจ๊ฐ€ ์–ด๋Š์ •๋„ ์žˆ๊ฒ ์ง€๋งŒ, ๋งˆ์ง€๋ง‰ ์กฐ๊ฑด์˜ ๊ฒฝ์šฐ 5ms ์ฐจ์ด๊ฐ€ ๋‚ฌ๋‹ค.
36. [x๋งŒํผ ๊ฐ„๊ฒฉ์ด ์žˆ๋Š” n๊ฐœ์˜ ์ˆซ์ž](https://programmers.co.kr/learn/courses/30/lessons/12954)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/xdistancenumbers/Solution.java)
- ์ƒ๊ฐํ•  ์—ฌ์ง€๊ฐ€ ๋ณ„๋กœ ์—†๋Š” ๋ฌธ์ œ์˜€๋‹ค.
37. [์ง์‚ฌ๊ฐํ˜• ๋ณ„์ฐ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/12969)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/makerectangle/Solution.java)
- ์ด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ์™œ ์žˆ์„๊นŒ... ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋Š” ๊ท€์ฐฎ์•„์„œ ๋งŒ๋“ค์ง€ ์•Š์•˜๋‹ค.
38. [์˜ˆ์‚ฐ](https://programmers.co.kr/learn/courses/30/lessons/12982)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/budget/Solution.java)
- ๊ดœ์ฐฎ์€ ๋ฌธ์ œ์˜€๋‹ค. nlogn์ด ์ตœ์„ ์˜ ๋ฐฉ๋ฒ•์ด๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค.
39. [๋น„๋ฐ€์ง€๋„](https://programmers.co.kr/learn/courses/30/lessons/17681)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/secretmap/Solution.java)
- ์ถœ๋ ฅ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์„œ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๊ฐ€ ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์•˜๋‹ค. ๋•๋ถ„์— ๊ณต๋ฐฑ์ด ์ค‘๋ณต๋˜๋ฉด ์ œ๊ฑฐํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋„ฃ์–ด์•ผ ํ•˜๋Š”์ค„ ์•Œ๊ณ  ๋ฌธ์ œ๋ฅผ ๋‹ค์‹œ ์ฝ์–ด๋ดค๋‹ค.
- ๊ทธ๊ฑด ๋…ผ์™ธ๋กœ ์น˜๊ณ  ๋ฌธ์ œ์ž์ฒด๋Š” ๊ดœ์ฐฎ์•˜๋‹ค. binaryString์„ ์‚ฌ์šฉํ•˜๋Š” ํ’€์ด๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ, ๋‚ด ํ’€์ด์— ์•ฝ 10๋ฐฐ์ด์ƒ์ด ๊ฑธ๋ ธ๋‹ค. ์™œ๋ƒ๋ฉด GC๊ฐ€ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋ผ ์ƒ๊ฐํ•œ๋‹ค.
- ์žฌ๊ท€ํ•จ์ˆ˜๋กœ ํ‘ธ๋Š” ํ’€์ด๋„ ์žˆ๋Š”๋ฐ, ๊ดœ์ฐฎ์€ ๊ฒƒ ๊ฐ™๋‹ค. ์ผ๋‹จ ๋ฌธ์ œ ์กฐ๊ฑด ์ž์ฒด๊ฐ€ 16์ž๋ฆฌ๊นŒ์ง€ ๋ฐ›์œผ๋‹ˆ๊นŒ...
- ๋น„ํŠธ์—ฐ์‚ฐ, ๋น„ํŠธ ์‹œํ”„ํŠธ์—ฐ์‚ฐ์œผ๋กœ ํ’€์ดํ•œ ๊ฒƒ์„ ๋ดค๋Š”๋ฐ, ์ž˜ ์•ˆ์จ์„œ ๊ทธ๋Ÿฐ๊ฐ€ ์–ด๋–ป๊ฒŒ ๋™์ž‘ํ• ์ง€ ์˜ˆ์ธก์ด ๋˜์ง€ ์•Š์•˜๋‹ค. ๋” ๊ณต๋ถ€ํ•ด์•ผ๊ฒ ๋‹ค.
40. [์‹คํŒจ์œจ](https://programmers.co.kr/learn/courses/30/lessons/42889)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/failurerate/Solution.java)
- ์ž˜ ์•ˆํ’€๋ ค์„œ ํ’€์ด๋ฅผ ์ฐพ์•„๋ดค๋Š”๋ฐ ๊ดœ์ฐฎ์€ ํ’€์ด๊ฐ€ ์—†์–ด์„œ ๋‹ค์‹œ ํ’€์—ˆ๋‹ค...
- 23, 24๋ฒˆ ์ผ€์ด์Šค์—์„œ ์‹คํŒจํ•˜๋Š”๋ฐ ์ผ๋‹จ, ์—ฌ๊ธฐ๊นŒ์ง€ ํ•œ ๊ฑธ ์˜ฌ๋ ค๋‘”๋‹ค.
- double ํ˜•์œผ๋กœ ํ–ˆ๋”๋‹ˆ ์ œ๋Œ€๋กœ ๋™์ž‘ํ–ˆ๋‹ค. overflow ๋ฌธ์ œ์ผ๊นŒ?
41. [๋‹คํŠธ ๊ฒŒ์ž„](https://programmers.co.kr/learn/courses/30/lessons/17682)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/dartgame/Solution.java)
- ์ •๊ทœํ‘œํ˜„์‹์œผ๋กœ ํ’€์–ด๋ณด์•˜๋‹ค.
- ์ˆ˜๋Ÿ‰์ž๋กœ๋Š” ๊ทธ๋ฃนํ•‘์ด ์•ˆ๋ผ์„œ ๊ฐ๊ฐ ์จ์ฃผ์—ˆ๋‹ค.
- `find()`๋ฅผ ์จ์ค˜์•ผ ํ•˜๋Š”๊ฑธ ์ฒ˜์Œ ์•Œ์•˜๋‹ค. `group(num)` ์ด `num` ์ด 0์ด๋ฉด ์ „์ฒด ๋‹ค๊ฐ€์ ธ์˜ค๋Š”๊ฑฐ์˜€๋‹ค.
- ์ƒ๊ฐ๋ณด๋‹จ ์‰ฝ๊ฒŒ ํ’€์–ด๋‚ธ ๊ฒƒ ๊ฐ™์€๋ฐ, ๋‚˜์ค‘์— ํ’€๋ฉด ๋” ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ?
- flow ๋•Œ๋ฌธ์— ์ฝ”๋“œ๊ฐ€ ์„ธ๋กœ๋กœ ๊ธธ์–ด์ ธ์„œ ์ข€ ์Šฌํ”„๋‹ค.
42. [๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ](https://programmers.co.kr/learn/courses/30/lessons/42583) {๋‹ค์‹œ ํ’€์–ด๋ณผ ๋ฌธ์ œ}
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/truckpassingbridge/Solution.java)
- ์—ฌ๋Ÿฌ ๋Œ€์˜ ํŠธ๋Ÿญ์ด **์ผ์ฐจ์„ ** ๋‹ค๋ฆฌ๋ฅผ **์ •ํ•ด์ง„** ์ˆœ์œผ๋กœ ๊ฑด๋„ˆ๋ ค ํ•œ๋‹ค. => Queue ์ž๋ฃŒ๊ตฌ์กฐ
- ๋ชจ๋“  ํŠธ๋Ÿญ์ด ๋‹ค๋ฆฌ๋ฅผ ๊ฑด๋„ˆ๋ ค๋ฉด ์ตœ์†Œ ๋ช‡ ์ดˆ๊ฐ€ ๊ฑธ๋ฆฌ๋Š”์ง€ ์•Œ์•„์•ผ ํ•œ๋‹ค.
- ํŠธ๋Ÿญ์€ 1์ดˆ์— 1๋งŒํผ ์›€์ง์ธ๋‹ค. ๋‹ค๋ฆฌ์˜ ๊ธธ์ด๋Š” bridgeLength ๊ฐ’์ด๊ณ , ๋ฌด๊ฒŒ๋Š” weight๋งŒํผ ๊ฒฌ๋”˜๋‹ค.
- ์ด ๋ฌธ์ œ๋Š” ํ๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฌธ์ œ์ง€๋งŒ, ๊ฐ์ฒด์ง€ํ–ฅ์ ์œผ๋กœ ํ’€์–ด๋ณผ ๋ฌธ์ œ์˜€๋‹ค.
- ๋‚˜๋Š” ์ ‘๊ทผ์„ ํ๋งŒ ์‚ฌ์šฉํ•ด์„œ ์ €์žฅํ•˜๊ณ  ๊บผ๋‚ด๋Š” ๋ฐฉ์‹๋งŒ ์‚ฌ์šฉํ•˜์˜€๊ณ , ์‹œ๊ฐ„์„ ์ „ํ˜€ ๊ณ ๋ คํ•˜์ง€ ๋ชปํ–ˆ๋‹ค.
- ๋Œ€๋ถ€๋ถ„์˜ ํ’€์ด๋Š” ์‹œ๊ฐ„์ด๋‚˜ ์›€์ง์ž„์„ ๊ณ„์‚ฐํ–ˆ๊ณ , ์ด๋Ÿฐ ๋ฐฉ์‹์„ ์ž˜ ์ƒ๊ฐํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.
- [ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํ’€์ด](https://programmers.co.kr/learn/courses/30/lessons/42583/solution_groups?language=java)
- ๋ถ€์กฑํ•จ์„ ๋งŽ์ด ๋Š๋‚€ ๋ฌธ์ œ์˜€๋‹ค. ์ž์ฃผ์ž์ฃผ ํ’€์–ด๋ณด์ž.
43. [ํ”„๋ฆฐํ„ฐ](https://programmers.co.kr/learn/courses/30/lessons/42587)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/printer/Solution.java)
- ์šฐ์„ ์ˆœ์œ„ ํ๋ฅผ ์‘์šฉํ•˜๋Š” ๋ฌธ์ œ๊ฐ™๋‹ค.
- ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ณ„์† ๋ณ€๊ฒฝ๋˜๋Š” ํฌ์ธํŠธ๋ฅผ ์ž˜ ์žก์ง€ ๋ชปํ•ด์„œ ํ’€์ด๋ฅผ ๊ฒ€์ƒ‰ํ–ˆ๋‹ค.
- ๋‚˜์ค‘์— ๋‹ค์‹œ ํ’€์–ด๋ณด์ž.
44. [๊ธฐ๋Šฅ๊ฐœ๋ฐœ](https://programmers.co.kr/learn/courses/30/lessons/42586)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/featuredevelop/Solution.java)
- ๋จผ์ € ์ž‘์—…์ด ์‹œ์ž‘ํ•œ ๊ฒฝ์šฐ ๋‹ค์Œ ๊ธฐ๋Šฅ์€ ๊ฐœ๋ฐœ์ด ์™„๋ฃŒ๋˜๋”๋ผ๋„ ๋ฐฐํฌ๋˜์ง€ ์•Š๋Š”๋‹ค.
- ๊ฐ์ฒด์ง€ํ–ฅ์ ์œผ๋กœ ์ ‘๊ทผํ–ˆ๋”๋‹ˆ ์ƒ๋‹นํžˆ ์ž˜ ํ’€๋ ธ๋‹ค. 20๋ถ„ ์ข€ ๋„˜๊ฒŒ ๊ฑธ๋ ธ๋‚˜?
- ๋žŒ๋‹ค์‹์„ ์ ๊ทน ํ™œ์šฉํ•œ ํ’€์ด๋„ ์ข‹์•„๋ณด์ธ๋‹ค.
- ๋™์‹œ์— ์Šคํƒ์„ ํ™œ์šฉํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ–ˆ๋‹ค. ๊ฒฐ๊ตญ Queue ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„์ฒด๋Š” LinkedList์ด๋ฏ€๋กœ iterator๋„ ํ™œ์šฉํ•ด๋ณด์•˜๋‹ค.
- ์‹œ๊ฐ„์€ ๊ฑฐ์˜ 2ms ๋‚ด์™ธ๋กœ ๊ฑธ๋ ธ๋‹ค. 0์ด ๋“ค์–ด๊ฐ€๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ, ์˜ˆ์™ธ์ฒ˜๋ฆฌ๊ฐ€ ์ข€ ์•„์‰ฝ๊ธด ํ•˜๋‹ค.
45. [์ฃผ์‹๊ฐ€๊ฒฉ](https://programmers.co.kr/learn/courses/30/lessons/42584)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/stockprice/Solution.java)
- ์ด์ „ ๊ฐ€๊ฒฉ๊ณผ ๋‹ค์Œ ๊ฐ€๊ฒฉ์„ ๋น„๊ตํ•˜๋ฉด์„œ ์ž‘์•„์ง€๋ฉด ์นด์šดํŠธ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ณ„์‚ฐํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- 100000๊ฐœ๋ผ๋ฉด ์ตœ๋Œ€ n^2 ๊นŒ์ง€๋งŒ ๊ฐ€๋Šฅํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์Šคํƒ์„ ์‚ฌ์šฉํ•ด์„œ ํ’€์–ด๋ณด๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ†ต๊ณผํ•˜๋Š”๋ฐ ๋‹ค๋ฅธ๊ฑด ํ†ต๊ณผํ•˜์ง€ ๋ชปํ•ด์„œ ๊ทธ๋ƒฅ for loop๋กœ ํ•ด๊ฒฐํ•ด๋ณด๋ ค๊ณ ํ•œ๋‹ค.
- for loop๊ฐ€ ํ›จ์”ฌ ์ง๊ด€์ ์œผ๋กœ ์ฝ”๋“œ๊ฐ€ ๋“ค์–ด์˜ค๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ทธ๋ฆฌ๊ณ  O(n^2)๊ฐ€ ์•„๋‹ˆ๋ฉด ์•ˆ๋˜๋Š” ๊ฒƒ์ธ์ง€... ์Šคํƒ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ ์šฉํ•ด๋„ ๋ฌธ์ œํ’€์ด๋Š” ๋˜‘๊ฐ™์•„์„œ... ๋ฌธ์ œ๊ฐ€ ์ž˜๋ชป๋œ๊ฑด ์•„๋‹๊นŒ ์ƒ๊ฐํ•œ๋‹ค.
46. [ํƒ‘](https://programmers.co.kr/learn/courses/30/lessons/42588)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/tower/Solution.java)
- ๋†’์ด๊ฐ€ ๊ฐ™์œผ๋ฉด ์ˆ˜์‹ ํ•  ์ˆ˜ ์—†๋‹ค.
- ์ˆ˜์‹ ํ•˜๋Š” ํƒ‘์ด ๋ฐ”๋กœ ๋“ค์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค.
- ์Šคํƒ์œผ๋กœ ํ’€๋ฉด ๋” ์–ด๋ ค์šธ ๊ฒƒ ๊ฐ™์€ ๋Š๋‚Œ์ด ๋“ ๋‹ค. ๊ทธ๋ž˜์„œ ์ผ๋‹จ ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.
- ์ด์ค‘ ํฌ๋ฌธ์ด ๋‚˜์˜ฌ ์ˆ˜ ๋ฐ–์— ์—†๋Š” ๋ฌธ์ œ๊ณ  ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ํ’€์ด๋ฅผ ์ƒ๊ฐํ•ด๋ƒˆ๋‹ค.
- ์Šคํƒ์„ ํ™œ์šฉํ•œ ๊ฒƒ๊ณผ ๋ณ„๋ฐ˜ ๋‹ค๋ฅผ๋ฐ” ์—†๋Š” ํ’€์ด์˜€๋‹ค.
47. [๋ฉ€์ฉกํ•œ ์‚ฌ๊ฐํ˜•](https://programmers.co.kr/learn/courses/30/lessons/62048)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/finesquare/Solution.java)
- ๊ฐ€๋กœ ๊ธธ์ด w, ์„ธ๋กœ ๊ธธ์ด h์ธ ์ง์‚ฌ๊ฐํ˜• ์ข…์ด
- ๋Œ€๊ฐ์„  ๊ผญ์ง€์  ๋ผ๋ฆฌ ์ž‡๋Š” ์ง์„ ์œผ๋กœ ๋‚˜๋ˆ„์–ด์ ธ์žˆ๋‹ค.
- ๊ฐ€๋กœ ์„ธ๋กœ 1cm์˜ ์ •์‚ฌ๊ฐํ˜•์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋งŒํผ๋งŒ ์‚ฌ์šฉ.
- ์ „์ฒด๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒƒ์€ w * h
- ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์˜ ๊ฐœ์ˆ˜๋Š” ์–ด๋–ป๊ฒŒ ๊ตฌํ• ๊นŒ?
- 1 * 2 ๋ผ๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์€ 2๊ฐœ
- 1 * 3 ์ด๋ผ๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์€ 3๊ฐœ
- 2 * 3 ์ด๋ผ๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์€ 4๊ฐœ
- 2 * 4 ๋ผ๋ฉด 4๊ฐœ (1 * 2)์˜ ํ™•์žฅ์ด๋ฏ€๋กœ...
- 3 * 4 ๋ผ๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์€ 6๊ฐœ
- 3 * 5 ๋ผ๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์€ 7๊ฐœ
- ์ง์‚ฌ๊ฐํ˜• ์ด๋ฏ€๋กœ ์ •์‚ฌ๊ฐํ˜•์ธ ๊ฒฝ์šฐ๋Š” ๊ณ ๋ คํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.
- ์˜ˆ์ œ ์กฐ๊ฑด๋„ ๊ฒฐ๊ตญ 1 * 2 ํŒจํ„ด์ด 8๋ฐฐ๋œ ๊ฒƒ์ด์–ด์„œ 16๊ฐœ์ด๋‹ค.
- ๊ทธ๋Ÿฌ๋ฉด ์–ด๋–ป๊ฒŒ ๋Œ€๊ฐ์„  ํŒจํ„ด์„ ๊ตฌํ•  ์ˆ˜ ์žˆ์„๊นŒ?
- ๋ณด๋ฉด w + h - 1์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ์นธ์˜ ๊ฐœ์ˆ˜์ด๋‹ค.
- ์ด๊ฒŒ ํ™•์žฅ๋œ๋‹ค๋ฉด? ์•„๋งˆ (w/์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ + h/์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ - 1) * ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ์ผ ๊ฒƒ์ด๋‹ค. ์ฆ‰ w + h - ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ์ด๋‹ค.
- ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜๋Š” ์–ด๋–ป๊ฒŒ ๊ตฌํ•˜๋”๋ผ.. ์˜ˆ์ „์— ํ‘ผ ๋ฌธ์ œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ for๋ฌธ์„ ๋Œ๋ ธ๋˜ ๊ฒƒ ๊ฐ™์œผ๋‹ˆ ์ ์šฉํ•œ๋‹ค.
- ์—ฌ๊ธฐ์„œ input์˜ ํฌ๊ธฐ๊ฐ€ 1์–ต์ด๋ฏ€๋กœ O(n)๋งŒ ๊ฐ€๋Šฅํ•จ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
- ์ „์ฒด ๊ฐœ์ˆ˜ - ์‚ฌ์šฉ๋ถˆ๊ฐ€๋Šฅํ•œ ๊ฐœ์ˆ˜ = ์ •๋‹ต.
- ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ค‘ ํ•˜๋‚˜์ธ ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋ฉด ๋” ๋‚˜์€ ๊ฒƒ ๊ฐ™๋‹ค.
- ```java
public int gcd(int p, int q) {
if (q == 0) {
return p;
}
return gcd(q, p % q);
}
```
์‹œ๊ฐ„ ๋ณต์žก๋„๊ฐ€ O(log(n+m)) ์ด๋ผ๊ณ  ํ•œ๋‹ค.
48. [์Šคํ‚ฌํŠธ๋ฆฌ](https://programmers.co.kr/learn/courses/30/lessons/49993)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/skilltree/Solution.java)
- ๊ฒŒ์ž„์— ์ต์ˆ™ํ•ด์„ ์ง€ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ๋ฌธ์ œ๊ฐ€ ์ข€ ์ด์ƒํ–ˆ๋‹ค.
- ์–ด์จŒ๋“  ์ค‘์š”ํ•œ ๊ฒƒ์€ ์ˆœ์„œ๊ฐ€ ์ •ํ•ด์ ธ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์กด์žฌ ์œ ๋ฌด๋กœ ํŒ๋‹จํ•˜๋ฉด ์•ˆ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  -> ์ˆœ์„œ์— ๋งž๋Š”์ง€ ํ™•์ธํ•ด์•ผ ๋งž์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ณ„๋‹ค๋ฅธ edge case๊ฐ€ ์žˆ์„๊นŒ? ์กฐ๊ฑด์ด ๋˜๊ฒŒ ๋งŽ์•„์„œ ๊ทธ๋Ÿด ์ผ์€ ์—†์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ์ •๊ทœํ‘œํ˜„์‹์œผ๋กœ ํ’€๋ฉด ์–ด๋–จ๊นŒ?
- ํ•˜๋‚˜ ๋นผ๋จน์€๊ฒŒ ์žˆ์—ˆ๋‹ค. ์Šคํ‚ฌํŠธ๋ฆฌ์—์„œ ์•ˆ๋ฐฐ์šฐ๋Š” ๊ฒฝ์šฐ๋„ ์กด์žฌํ–ˆ๋‹ค. ๋”ฐ๋ผ์„œ .*๋กœ ์ž‡๋Š” ๋ฐฉ๋ฒ•์€ ๋ถˆ๊ฐ€๋Šฅ
- skill์„ ์ œ์™ธํ•œ ๋ฌธ์ž์—ด์„ ์—†์•ค๋‹ค๋ฉด? ๊ทธ๋Ÿฌ๋ฉด ์Šคํ‚ฌ ์ข…๋ฅ˜๋งŒ ๋‚จ์ง€ ์•Š์„๊นŒ?
- ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ skill.indexOf๋ฅผ ๋จน์ด๋ฉด ์œ„์น˜๊ฐ€ 0์œผ๋กœ ๋‚˜์˜ค์ง€ ์•Š์„๊นŒ?
- ์†๋„๋Š” 20ms ์ •๋„ ๋‚˜์™”๋‹ค.
49. [์‡ ๋ง‰๋Œ€๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/42585)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/ironbar/Solution.java)
- ์ตœ๋Œ€ O(n^2) solution์ด ๋‚˜์™€์•ผํ•œ๋‹ค.
- ์Œ์„ ์ด๋ฃจ๋‹ˆ ์Šคํƒ์„ ํ™œ์šฉํ•œ ๋ฌธ์ œ์ผ ๊ฒƒ ๊ฐ™๋‹ค.
- ์Šคํƒ์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์—ˆ๋Š”๋ฐ ๋ ˆ์ด์ € ๋ถ€๋ถ„์—์„œ ๋ฌธ์ œ๊ฐ€ ๋˜์—ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์€ ๋ ˆ์ด์ €๋ฅผ replaceํ•˜๋Š” ์‹์œผ๋กœ ํ’€์—ˆ๋‹ค.
- ๊ทธ๋ƒฅ ๋”ํ•˜๊ณ  ๋นผ๋Š” ๋ฐฉ๋ฒ•๋„ ๊ฐ€๋Šฅํ•ด์„œ ์ด๋ ‡๊ฒŒ ํ’€์—ˆ๋‹ค.
- ์Šคํƒ์„ ์“ฐ๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€ ์ €์žฅ์„ ํ•  ์šฉ๋„๋กœ ์จ์•ผํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
- ๋‹ค๋“ค ์˜๋ฏธ์—†๋Š” ๊ฐ’์„ pushํ•˜๊ณ  pop์„ ํ•œ๋‹ค. peek๋งŒ ์“ฐ์ž„์ด ์กฐ๊ธˆ ์žˆ์—ˆ๋‹ค.
- ์Šคํƒ ํ’€์ด๋„ ์ฃผ์˜๊นŠ๊ฒŒ ๋ด๋‘๊ธด ํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.
50. [์นด์นด์˜คํ”„๋ Œ์ฆˆ ์ปฌ๋Ÿฌ๋ง๋ถ](https://programmers.co.kr/learn/courses/30/lessons/1829)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/coloringbook/Solution.java)
- ์ˆœํšŒ๋ฅผ ์ด์šฉํ•ด์„œ ํ’€์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์™ผ์ชฝ, ์•„๋žซ์ชฝ์„ ์ฒดํฌํ•ด์„œ ๊ฐ™๋‹ค๋ฉด ๊ฐ™์€ ์˜์—ญ์ด๋‹ค.
- HashMap์„ ์จ์„œ ํ’€๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ์ค‘๋ณต๋˜๋Š” Key๋ฅผ ๊ฐ€์ง€๋Š” ์˜์—ญ์€ ์–ด๋–ป๊ฒŒํ•˜์ง€?
- ์งˆ๋ฌธ์„ ๋ณด๋‹ˆ BFS ๋ฌธ์ œ๊ฐ™๋‹ค. BFS๋Š” ์ž˜ ๋ชฐ๋ผ์„œ ํ’€์ด๋ฅผ ๋ณด๋ฉด์„œ ๋”ฐ๋ผ๊ฐ€๊ธฐ๋กœ ํ–ˆ๋‹ค.
- BFS์˜ ํ•ต์‹ฌ์€ ์ด๋ฏธ ๋ฐฉ๋ฌธํ•œ ๊ณณ์€ ๋‹ค์‹œ ์ฒดํฌํ•˜์ง€ ์•Š๊ฒŒ๋” ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
51. [์†Œ์ˆ˜ ์ฐพ๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/42839)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/findprime/Solution.java)
- ์ตœ๋Œ€ 7์ž๋ฆฌ์˜ ์ˆซ์ž๊ฐ€ ๋งŒ๋“ค์–ด์งˆ ์ˆ˜ ์žˆ๋‹ค.
- ๋งŒ๋“ค์–ด์งˆ ์ˆ˜ ์žˆ๋Š” ์ˆ˜๋ฅผ ๋ชจ๋‘ ๋งŒ๋“ค๊ณ  ์ด ์ˆ˜๊ฐ€ ์†Œ์ˆ˜์ธ์ง€ ํŒ๋‹จํ•ด์•ผ ํ•œ๋‹ค.
- ์ผ๋‹จ ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด๋ฅผ ์ ์šฉํ•˜๋Š” ๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค. length๋ฅผ ๊ฐ€์ง€๊ณ  ํŒ๋‹จํ•œ๋‹ค. ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” O n log log n ์ด๋ผ๊ณ  ํ•œ๋‹ค.
- ์ˆซ์ž ์กฐํ•ฉ์€ ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„๊นŒ? ์ด๊ฒŒ ์ „์ฒด ๋‹ค ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์ผ๋ถ€๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๋Š”๋ฐ... ๊ฒฝ์šฐ์˜ ์ˆ˜๊ฐ€ ๋„ˆ๋ฌด ๋งŽ๋‹ค.
- ์ˆœ์—ด ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ๋Œ€ํ•ด์„œ ์ฐพ์•„๋ณด์•˜๋‹ค. (https://gorakgarak.tistory.com/522)
- ์ˆœ์—ด์ด ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ„๋‹ค... ํ‘ํ‘... ๋‚˜์ค‘์— ๋‹ค์‹œ ํ’€์–ด๋ณด์ž
52. [ํฐ ์ˆ˜ ๋งŒ๋“ค๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/42883)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/makebignumber/Solution.java)
- ๊ทธ๋ƒฅ ์—ญ์ˆœ ์ •๋ ฌ์„ ํ•ด์„œ String์„ ๋งŒ๋“ค๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ์ž˜๋ชป๋œ ์ ‘๊ทผ ๋ฐฉ๋ฒ•์ธ ๊ฒƒ ๊ฐ™๋‹ค. sorting์„ ํ•˜์ง€ ์•Š๊ณ  ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ์ตœ๊ณ ๋กœ ํฐ ์ˆ˜๋ฅผ ์ฐพ์•„๋‚ด๋Š” ๋ฌธ์ œ๊ฐ™๋‹ค.
- ํƒ์š•๋ฒ•์ด๋ผ๊ณ  ํ•˜์˜€์œผ๋‹ˆ, ๊ทธ ๋•Œ ์ƒํ™ฉ์—์„œ์˜ ์ตœ์„ ์˜ ์„ ํƒ์„ ํ•˜๋Š”๊ฒŒ ๋งž๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ฐฑ๋งŒ์ž๋ฆฌ๋‹ˆ๊นŒ O(n^2) ํ’€์ด๋„ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ์ตœ๋Œ€ nlogn์ด ํ•œ๊ณ„์ธ ๊ฒƒ ๊ฐ™๋‹ค. ํ•˜์ง€๋งŒ, ์ •๋ ฌ๋„ ์•ˆ๋˜์–ด์žˆ์–ด์„œ ๊ทธ๋ƒฅ n^2 ํ’€์ด๊ฐ€ ์•ˆ๋œ๋‹ค๊ณ ๋งŒ ์ดํ•ดํ•˜๊ณ  ์žˆ์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์ œ๊ฑฐ๊ฐ€๋Šฅํ•œ ์ˆซ์ž์˜ ๊ฐœ์ˆ˜๋งŒํผ ๋ฐ˜๋ณต๋ฌธ๋“ค ์ˆ˜ํ–‰ํ•˜๋„๋ก ํ•˜์˜€๋‹ค.
- ์™œ ๊ทธ๋ฆฌ๋””๊ฐ€ ์ ์šฉ ๊ฐ€๋Šฅํ•œ๊ฐ€? ์ˆซ์ž๋ฅผ ์ œ๊ฑฐํ•  ๋•Œ, ์ฒ˜์Œ๋ถ€ํ„ฐ ์ž‘์€ ์ˆ˜๋ฅผ ์ œ๊ฑฐํ•ด ๋‚˜๊ฐ€๋‹ค ๋ณด๋ฉด ์ •๋‹ต์ด ๋˜๋Š” ๋ฅ˜์˜ ๋ฌธ์ œ๋‹ค.
- ์ฆ‰, ๋ถ€๋ถ„์˜ ์ตœ์ ํ•ด๊ฐ€ ์ „์ฒด์˜ ์ตœ์ ํ•ด๊ฐ€ ๋˜๋Š” ๋ฅ˜์˜ ๋ฌธ์ œ๋‹ค.
- ์ฝ”๋“œ๋Š” ๊ฐ„๋‹จํ•˜๊ฒŒ ๋‚˜์™”๋Š”๋ฐ, ์–ด๋ ต๋‹ค..
- ์ตœ์ดˆ์œ„์น˜ ์ง€์ •์„ 0๋ฒˆ์งธ๋กœ ํ•ด๋‘๋ฉด ์•ˆ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค. Edge ์ผ€์ด์Šค๋Š” ๋ฌด์—‡์ผ๊นŒ?
- ์ผ๋‹จ ๋งˆ์ง€๋ง‰ index๋กœ ๋ณ€๊ฒฝํ–ˆ๋”๋‹ˆ ์ž˜ ๋™์ž‘ํ•œ๋‹ค. Edge ์ผ€์ด์Šค๋Š” ์ƒ๊ฐํ•ด๋ด์•ผ๊ฒ ๋‹ค.
53. [์กฐ์ด์Šคํ‹ฑ](https://programmers.co.kr/learn/courses/30/lessons/42860)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/programmers/joystick/Solution.java)
- ํ•ญ์ƒ ์ตœ์„ ์˜ ์„ ํƒ์„ ํ•ด์•ผํ•œ๋‹ค.
- ๋Œ€๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ์œผ๋ฏ€๋กœ char ๋บ„์…ˆ์ด ๊ฐ€์žฅ ์ ์€ ์ƒํ™ฉ์„ ๊ณ ๋ คํ•˜๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ๊ฐ€์šด๋ฐ ๋ฌธ์ž๊ฐ€ ๋ฌด์—‡์ด์ง€? M?
- ์ผ๋‹จ ๋ชจ๋“  ๊ธ€์ž๋ฅผ ์ˆœํšŒํ•ด์•ผ ๋œ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์™ผ์ชฝ ์˜ค๋ฅธ์ชฝ์ธ์ง€๋„ ํŒ๋‹จํ•ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
- ์œ„ ์•„๋ž˜ ํŒ๋‹จ์€ char ์—ฐ์‚ฐ, ์ขŒ์šฐ ํŒ๋‹จ์€ index ์—ฐ์‚ฐ์œผ๋กœ ๊ณ„์‚ฐํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- int type์œผ๋กœ ์ถฉ๋ถ„ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์ผ๋‹จ ๋ชจ๋“  ๋ฌธ์ž๋Š” ์›€์ง์—ฌ์•ผ ํ•˜๋ฏ€๋กœ ์ด๋ฅผ ๋‹ต์— ๋”ํ•ด์ค€๋‹ค.
- ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ ์ตœ์†Œ ์ด๋™๊ฑฐ๋ฆฌ๋ฅผ ๋”ํ•ด์ฃผ๋ฉด ๋!
- [์ฐธ๊ณ ](https://keepgoing0328.tistory.com/71)
- ๊ทธ๋ฆฌ๋””๋กœ ํ’€๋ฉด ์•ˆ ํ’€๋ฆฌ๋Š” ์ผ€์ด์Šค๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜์ง€๋งŒ, ์–ด์ฐŒ๋˜์—ˆ๋“  ํ†ต๊ณผ๋Š” ํ–ˆ๋‹ค.
- ์ ์  ์–ด๋ ค์›Œ์ง„๋‹ค... ์–ด๋–ป๊ฒŒ ๊ณต๋ถ€ํ•ด์•ผํ•˜๋Š” ๊ฑธ๊นŒ...

---

## [LeetCode](https://leetcode.com/)

1. [Reverse Integer](https://leetcode.com/problems/reverse-integer/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/reverseinteger/Solution.java)
2. [Two Sum](https://leetcode.com/problems/two-sum/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/twosum/Solution.java)
3. [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/removeduplicates/Solution.java)
- ๋‚ด๋ถ€ ๋ฐฐ์—ด ์กฐ์ •ํ•œ ๊ฒƒ์„ ์–ด๋–ป๊ฒŒ ํ…Œ์ŠคํŠธํ•ด์•ผํ•˜๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ์Œ.. ์ฐพ์•„๋ณด๊ธฐ!!
- LeetCode ์†”๋ฃจ์…˜์„ ๋ดค๋Š”๋ฐ ๋ฌธ์ œ๋ฅผ ์ž˜๋ชป ์ดํ•ดํ–ˆ์—ˆ๋‹ค!
4. [Happy Number](https://leetcode.com/problems/happy-number/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/happynumber/Solution.java)
- ์ฒ˜์Œ์— String์œผ๋กœ ๋งŒ๋“ค์–ด์„œ ํ•ด๊ฒฐํ–ˆ๋Š”๋ฐ 31ms๊ฐ€ ๋‚˜์™”๋‹ค.
- ์ด๊ฒƒ์„ 10์œผ๋กœ ๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ๊ณผ ๋‚˜๋ˆ„๊ธฐ ์—ฐ์‚ฐ์„ ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ 8ms๊นŒ์ง€ ์ค„์˜€๋‹ค.
- Map์„ Set์œผ๋กœ ๋ฐ”๊พธ๋‹ˆ 1ms๊ฐ€ ๊ฑธ๋ ธ๋‹ค.
5. [Single Number](https://leetcode.com/problems/single-number/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/singlenumber/Solution.java)
- ์ฒ˜์Œ์— HashMap์„ ์ด์šฉํ•ด์„œ ํ•ด๊ฒฐํ–ˆ๋Š”๋ฐ 21ms๊ฐ€ ๋‚˜์™”๋‹ค.
- ๊ฐ™์€ ์ˆ˜๊ฐ€ 2๋ฒˆ๊นŒ์ง€๋งŒ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ๋น„ํŠธ xor์—ฐ์‚ฐ์„ ํ•˜๋ฉด ๊ฐ™์€ ์ˆ˜๋Š” 0์ด๋˜๊ณ , ํ•˜๋‚˜์ธ ์ˆ˜๋งŒ ๋‚จ๊ฒŒ๋˜์–ด ๊ฐ€์žฅ๋น ๋ฅธ ์†”๋ฃจ์…˜์ด๋‹ค.๐Ÿ˜ฎ
6. [Palindrome Number](https://leetcode.com/problems/palindrome-number)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/palindromenumber/Solution.java)
- String์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์†”๋ฃจ์…˜์„ ์‚ฌ์šฉํ–ˆ๋‹ค. ์—ญ์‹œ ์†๋„๋Š” ๋Š๋ฆฌ๋‹ค... Runtime: 13 ms, faster than 12.68%
- Solution์„ ๋”ฐ๋ผํ–ˆ๋‹ค. ์ตœ๋Œ€ํ•œ ์ฝ”๋“œ๋ฅผ ์ดํ•ดํ•˜๋Š”๋ฐ ์ฃผ์•ˆ์ ์„ ๋‘์—ˆ๋‹ค. Runtime: 6 ms, faster than 100.00%

### [LeetCode Challenge](https://leetcode.com/explore/)

#### May

1. [Ransom Note](https://leetcode.com/explore/featured/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3318/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/challenge/ransomnote/Solution.java)
- ์ฒ˜์Œ์—” HashMap์„ ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค. 53ms๊ฐ€ ๊ฑธ๋ ค์„œ ์ด ๋ฐฉ๋ฒ•์€ ๋Š๋ฆฌ๋‹ค๊ณ  ์ƒ๊ฐ๋๋‹ค.
- LeetCode์—์„œ ์ œ์ถœ๋œ ๋‹ต์•ˆ์ค‘ 0ms๊ฐ€ ๊ฑธ๋ฆฐ Solution์„ ๋ถ„์„ํ–ˆ๋‹ค.
- ๋‚˜์™€์˜ ์ฐจ์ด๋Š” HashMap์„ ๊ตณ์ด ์•ˆ์“ด ์ . split์œผ๋กœ ๋‚˜๋ˆ„์ง€ ์•Š๊ณ  CharArray๋ฅผ ์‚ฌ์šฉํ•œ ์ . indexOf๋ฅผ ํ™œ์šฉํ•œ ์ .
- ๊ทธ๋ƒฅ ๋„ˆ๋ฌด ์ž˜ํ•จ...

2. [Number Complement](https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3319/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/challenge/numbercomplement/Solution.java)
- ๋น„ํŠธ์—ฐ์‚ฐ์„ ํ™œ์šฉํ•ด๋ณด๊ณ  ์‹ถ์—ˆ๋‹ค.
- ์ฒ˜์Œ์— int ์ „์ฒด๋ฅผ byte๋กœ ๋ฐ”๊พธ๋Š” ๋ฐฉ๋ฒ•์„ ์ผ๋Š”๋ฐ, ์ด๊ฑด ๋ณด์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋ผ... ์Œ์ˆ˜๊ฐ€ ๋‚˜์™€๋ฒ„๋ ธ๋‹ค.
- ๊ฒฐ๊ตญ ์†”๋ฃจ์…˜์„ ์ฐพ์•„๋ดค๋‹ค. ๋งˆ์ง€๋ง‰ ๋น„ํŠธ๋ฅผ ๋ฐ”๋กœ ๋”ํ•˜๋Š”๊ฒŒ ํ•ต์‹ฌ์ธ๋“ฏ
- ๊ทธ๋ฆฌ๊ณ  0์ธ ๊ฒฝ์šฐ๋Š” ํŠน์ด์ผ€์ด์Šค๋ผ ๋ฐ”๋กœ ์ฒ˜๋ฆฌํ•ด์ค˜์•ผํ–ˆ๋‹ค.

3. [First Unique Character in a String](https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3320/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/challenge/firstuniquechar/Solution.java)
- ๋ฐ˜๋ณต๋˜์ง€ ์•Š๋Š” Character์ค‘ ๊ฐ€์žฅ ์•ž์— ์žˆ๋Š” ๊ฒƒ์˜ Index๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
- ์—†์œผ๋ฉด -1์„ ๋ฐ˜ํ™˜ํ•ด์•ผ ํ•œ๋‹ค.
- ๋ชจ๋‘ ์†Œ๋ฌธ์ž๋กœ ๊ฐ€์ •ํ•œ๋‹ค.
- ์ผ๋‹จ CharArray๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- 4ms๊ฐ€ ๋‚˜์™”๋‹ค.
- ๊ตณ์ด charArray๋กœ ๋ฐ”๊ฟ€ ํ•„์š”๊ฐ€ ์—†๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ์ž…๋ ฅ์˜ ๋ฒ”์œ„๊ฐ€ ์†Œ๋ฌธ์ž 'a' - 'z'์ด๋ฏ€๋กœ for๋ฌธ์„ ๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค.
- 1ms๊ฐ€ ๋‚˜์™”๋‹ค. ์‚ฌ์‹ค ์†”๋ฃจ์…˜์„ ๋ณด๊ณ  ํ–ˆ๋‹ค. ์–ด๋–ป๊ฒŒ lastIndex๋ž‘ ๊ฐ™์€์ง€ ๋น„๊ตํ•  ์ƒ๊ฐ์„ ํ–ˆ์ง€...

4. [Majority Element](https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3321/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/leetcode/challenge/majorityelement/Solution.java)
- array์˜ ํฌ๊ธฐ๋Š” n์ผ ๋•Œ, n/2 ๋ณด๋‹ค ๋งŽ์ด ๋“ฑ์žฅํ•˜๋Š” element๊ฐ€ majority element์ด๋‹ค.
- ๋นˆ ๋ฐฐ์—ด์€ ๋“ฑ์žฅํ•˜์ง€ ์•Š์œผ๋ฉฐ, majority element๋Š” ๋ฐ˜๋“œ์‹œ ์กด์žฌํ•œ๋‹ค.
- ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ์ผ์ผ์ด ์„ธ์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- HashMap์„ ์‚ฌ์šฉํ•ด์„œ ํ’€์–ด๋ณด์•˜๋‹ค. Runtime: 8 ms

---

## [BAEKJOON](https://www.acmicpc.net/)

1. [์ˆ˜ ์ •๋ ฌํ•˜๊ธฐ 3](https://www.acmicpc.net/problem/10989)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/sortnumber3/Main.java)
- count sort๋ฅผ ์ด์šฉํ•˜๋ฉด ๋” ๋น ๋ฅด๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋‹ค. (๋ฉ”๋ชจ๋ฆฌ๋„ ์ ๊ฒŒ๋จน๊ณ , ์†๋„๋„ O(nlogn) -> O(n)์ด๋ผ ๋” ๋น ๋ฅด๊ฒŒ ๋˜์—ˆ๋‹ค.)
2. [ํŠธ๋ฆฌ ์ˆœํšŒ](https://www.acmicpc.net/problem/1991)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/treetraversal/Main.java)
- ์ „์œ„ ์ˆœํšŒ, ์ค‘์œ„ ์ˆœํšŒ, ํ›„์œ„ ์ˆœํšŒ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ๋ชฐ๋ผ์„œ ํ™•์ธํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.
- ์ง์ ‘ Tree ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“ค์–ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.
- ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” ํ†ต๊ณผํ–ˆ๋‹ค.
- ๋ฐฑ์ค€์— ์ œ์ถœํ•œ ๊ฒฐ๊ณผ 76ms๊ฐ€ ๋‚˜์™”๋‹ค.
3. [A/B](https://www.acmicpc.net/problem/1008)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/adivideb/Main.java)
- ๋ธŒ๋ก ์ฆˆ 4 ๋ฌธ์ œ์˜€๋‹ค. ์ถœ๋ ฅ ์˜ˆ์ œ๋ฅผ ๋ณด์ง€ ์•Š๊ณ  ๊ทธ๋ƒฅ ๋งŒ๋“ค์—ˆ๋‹ค๊ฐ€ ํ‹€๋ ค๋ฒ„๋ ธ๋‹ค.
- ์ด ๋ฌธ์ œ์˜ ํ•ต์‹ฌ์€ ๋‚˜๋ˆ„๊ธฐ ์—ฐ์‚ฐ์„ ํ–ˆ์„ ๋•Œ, ์†Œ์ˆซ์  ๋ช‡ ๋ฒˆ์งธ ์ž๋ฆฌ๊นŒ์ง€ ํ‘œ์‹œํ•  ๊ฒƒ์ธ์ง€๊ฐ€ ํ•ต์‹ฌ์ธ ๊ฒƒ ๊ฐ™๋‹ค.
- `System.out.printf("%.#f%n", ํ‘œ์‹œํ•  ์ˆ˜ ํ˜น์€ ์—ฐ์‚ฐ);`
- ์—ฌ๊ธฐ์„œ #์€ ํ‘œ์‹œํ•  ์ž๋ฆฟ์ˆ˜๋ฅผ ์˜๋ฏธํ•œ๋‹ค.
4. [์‚ฌ์น™์—ฐ์‚ฐ](https://www.acmicpc.net/problem/10869)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/fourarithmetic/Main.java)
- ๋ธŒ๋ก ์ฆˆ 5 ๋ฌธ์ œ์˜€๋Š”๋ฐ ์ข€ ๋งŽ์ด ํ‹€๋ ธ๋‹ค.
- int ์—ฐ์‚ฐํ•˜๊ณ  ๋‚˜์„œ ์ ˆ๋Œ€ charํ˜•์„ ๊ทธ๋ƒฅ ๋”ํ•˜์ง€๋ง๊ณ  ๊ทธ๋ƒฅ Stringํ˜•์„ ๋ถ™์ด์ž. charํ˜•์ด ์ •์ˆ˜๊ฐ’์œผ๋กœ ๊ณ„์‚ฐ์ด ๋˜์–ด์„œ ๋ฌธ์ œ๋ฅผ ํ‹€๋ฆฌ๊ณ  ์žˆ์—ˆ๋‹ค.
- ๊ฐ€๊ธ‰์ ์ด๋ฉด ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์„œ ์›ํ•˜๋Š” ๋Œ€๋กœ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๋Š” ์Šต๊ด€์„ ๋‹ค์‹œ๊ธˆ ๋“ค์ด์ž.
- ๋ฐฑ์ค€ํ’€์ด๋Š” ํ…œํ”Œ๋ฆฟ์„ ๋งŒ๋“ค์–ด ๋†“๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.
5. [๋‚˜๋จธ์ง€](https://www.acmicpc.net/problem/10430)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/rest/Main.java)
- ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘์„ฑํ•ด์„œ ํ•œ ๋ฒˆ์— ์ •๋‹ต์„ ๋งž์ถœ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
6. [๊ณฑ์…ˆ](https://www.acmicpc.net/problem/2588)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/multifly/Main.java)
- ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘์„ฑํ•ด์„œ ํ•œ ๋ฒˆ์— ์ •๋‹ต์„ ๋งž์ถœ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
- ์ˆซ์ž๋Š” ๊ฑฐ๊พธ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค๋Š” ์ ์„ ๊ฐ„๊ณผํ•ด์„œ ํ…Œ์ŠคํŠธ์—์„œ ์‹คํŒจํ–ˆ์—ˆ๋‹ค. ์ฃผ์˜ํ•˜์ž.
7. [๋„ค ๋ฒˆ์งธ ์ ](https://www.acmicpc.net/problem/3009)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/fourthpoint/Main.java)
- XOR์—ฐ์‚ฐ์„ ์ด์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” ํ†ต๊ณผํ•˜๋Š”๋ฐ, ๋ฌธ์ œ๋Š” ํ‹€๋ ธ๋‹ค๊ณ  ๋‚˜์™”๋‹ค. ๋ญ๊ฐ€ ๋ฌธ์ œ์ธ์ง€ ์•„์ง ๋ชจ๋ฅด๊ฒ ๋‹ค.
- ๊ทธ๋ƒฅ ์žˆ๋Š”์ง€ ํ™•์ธํ•ด์„œ ํ‘ธ๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋Š”๋ฐ, ํŒŒ์ด์ฌ๋ณด๋‹ค ๋Š๋ ค์„œ ํ™•์ธ์ด ํ•„์š”ํ•˜๋‹ค.
8. [ํ•œ์ˆ˜](https://www.acmicpc.net/problem/1065)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/hansu/Main.java)
- ์–‘์˜ ์ •์ˆ˜ X์˜ ๊ฐ ์ž๋ฆฌ๊ฐ€ ๋“ฑ์ฐจ์ˆ˜์—ด์„ ์ด๋ฃฐ ๋•Œ, ์ด๋ฅผ ํ•œ์ˆ˜๋ผ๊ณ  ํ•œ๋‹ค.
- ์ด ๋•Œ, 1 <= ํ•œ์ˆ˜ <= N ์ธ ํ•œ์ˆ˜์˜ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•œ๋‹ค.
- ๋‘ ์ž๋ฆฌ์ˆ˜ ๊นŒ์ง€๋Š” ๋ฌด์กฐ๊ฑด ํ•œ์ˆ˜๋ผ๊ณ  ์นœ๋‹ค. (์˜ˆ์ œ ์ถœ๋ ฅ์— ๋”ฐ๋ฅด๋ฉด)
- ํ•œ์ˆ˜๋ฅผ ํŒ๋ณ„ํ•˜๋Š” ๊ฒƒ์€ 999๊นŒ์ง€๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.
- ํ•œ์ˆ˜ ๊ฒ€์ฆ ๋กœ์ง์€ ์ฒซ์งธ ์ž๋ฆฌ์ˆ˜, ๋‘˜์งธ ์ž๋ฆฌ์ˆ˜, ์…‹์งธ ์ž๋ฆฌ์ˆ˜๊ฐ€ ๊ฐ™์€์ง€ ๋น„๊ตํ•˜๋ฉด ๋œ๋‹ค.
- ์ฒ˜์Œ์— ์˜ˆ์ œ ์ž…๋ ฅ ์ถœ๋ ฅ์„ ์ž˜๋ชป๋ด์„œ ์ž˜๋ชป๋œ ๋กœ์ง์œผ๋กœ ์ž‘์„ฑํ•˜์˜€๋‹ค.
9. [์ง๊ฐ์‚ผ๊ฐํ˜•](https://www.acmicpc.net/problem/4153)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/righttriangle/Main.java)
- ํ”ผํƒ€๊ณ ๋ผ์Šค์˜ ์ •๋ฆฌ๋ฅผ ์‘์šฉํ•˜๋Š” ๋ฌธ์ œ
- ํ˜น์‹œ ๋ชฐ๋ผ์„œ sorting์„ ํ•ด์ฃผ์—ˆ๋‹ค.
10. [์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜](https://www.acmicpc.net/problem/2609)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/gcfandlcm/Main.java)
- ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋Š” ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ•์œผ๋กœ ํ‘ผ๋‹ค. ์—ฌ๊ธฐ์„œ ์กฐ๊ฑด์ด a > b ์—ฌ์•ผ ํ•˜๋ฏ€๋กœ Math.max์™€ Math.min์„ ์‚ฌ์šฉํ•œ๋‹ค.
- ์•„๋‹ˆ๋ฉด Arrays.sort๋ฅผ ์จ๋„ ๊ดœ์ฐฎ์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๋Š” (a / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜) * (b / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜) * ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ์ด๋ฏ€๋กœ a * b / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ์ด๋‹ค.
11. [์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜](https://www.acmicpc.net/problem/1934)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/lcm/Main.java)
- ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๋Š” ๊ฒฐ๊ตญ a * b / gcf๋กœ ๊ตฌํ•œ๋‹ค.
12. [GCD ํ•ฉ](https://www.acmicpc.net/problem/9613)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/gcdsum/Main.java)
- ์ „์ฒด ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๊ฒฝ์šฐ๋ฅผ ๋‹ค ๊ณ„์‚ฐํ•œ ํ•ฉ์„ ๊ตฌํ•ด์„œ ์ถœ๋ ฅํ•ด์•ผํ•œ๋‹ค.
- overflow๊ฐ€ ๋‚˜์„œ ํ‹€๋ ธ๋˜ ๋ฌธ์ œ๋‹ค. ์™ ๋งŒํ•˜๋ฉด Sumํ•˜๋Š” ์ž‘์—…์„ ํ•˜๋Š” ๋ณ€์ˆ˜๋Š” long ํƒ€์ž…์œผ๋กœ ๋‘๋Š” ํŽธ์ด ์ข‹๊ฒ ๋‹ค.
13. [์†Œ์ˆ˜ ์ฐพ๊ธฐ](https://www.acmicpc.net/problem/1978)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/findprime/Main.java)
- ์†Œ์ˆ˜๋ฅผ ์ฐพ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ๋”ฐ๋กœ ์žˆ์„๊นŒ?
- ์ผ๋‹จ ์ˆ˜ํ•™์  ์ •์˜์— ์ž…๊ฐํ•ด์„œ ํ’€์–ด๋ณด๋„๋ก ํ•˜์ž.(1๊ณผ ์ž๊ธฐ์ž์‹ ๋งŒ์œผ๋กœ ๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€๋Š” ์ˆ˜, ๋‹จ 1์€ ํฌํ•จํ•˜์ง€ ์•Š๋Š”๋‹ค.)
- ์ƒ๊ฐ๋ณด๋‹ค ์ฝ”๋“œ ์ตœ์ ํ™”๋ฅผ ์•ˆํ–ˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ, 76ms๋กœ ๋น ๋ฅธํŽธ์ด์—ˆ๋‹ค... ๋ญ์ง€...
14. [๊ณจ๋“œ๋ฐ”ํ์˜ ์ถ”์ธก](https://www.acmicpc.net/problem/6588)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/goldbach/Main.java)
- ์†Œ์ˆ˜๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ์ฐพ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ธ ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด๋ฅผ ๋ชจ๋ฅด๋ฉด ์‹œ๊ฐ„์ด ๋” ์˜ค๋ž˜ ๊ฑธ๋ฆด ๊ฒƒ ๊ฐ™์€ ๋ฌธ์ œ์˜€๋‹ค.
- 300ms ๋ผ์„œ ๋Š๋ฆฐํŽธ์ธ์ค„ ์•Œ์•˜๋Š”๋ฐ, ๋น ๋ฅธํŽธ์ด์—ˆ๋‹ค.
- ์‹ค๋ฒ„ 1์€ ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด๋ฅผ ๊ฐ์•ˆํ•ด์„œ ๋งค๊ฒจ์ง„ ๋“ฑ๊ธ‰์ธ ๊ฒƒ ๊ฐ™๋‹ค.
15. [๊ฑฐ์Šค๋ฆ„๋ˆ](https://www.acmicpc.net/problem/5585)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/changecash/Main.java)
- ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์ธ loop์™€ ์กฐ๊ฑด๋ฌธ์„ ํ†ตํ•ด์„œ ๋งŒ๋“ค์—ˆ๋‹ค.
- ์ฝ”๋“œ๋ผ์ธ์ด ๋„ˆ๋ฌด ๋ฌด์‹ํ•ด๋ณด์ด๋Š” ๋‹จ์ ์ด ์žˆ์ง€๋งŒ, ๊ฐ€์žฅ ๊ทธ๋ฆฌ๋””ํ•˜์ง€ ์•Š์„๊นŒ ์‹ถ๋‹ค.
16. [๋””์ง€ํ„ธ ํ‹ฐ๋น„](https://www.acmicpc.net/problem/2816)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/digitaltv/Main.java)
- ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ์กฐ์ด์Šคํ‹ฑ๊ณผ ๋น„์Šทํ•œ ๋ฌธ์ œ๋‹ค.
- ๋ฌธ์ œ์˜ ์š”๊ตฌ์‚ฌํ•ญ์€ KBS1์ด ์ฒซ ๋ฒˆ์งธ, KBS2๊ฐ€ ๋‘ ๋ฒˆ์งธ๋กœ ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ์ฐพ๋Š” ๊ฒƒ์ด๋‹ค.
- ์กฐ์ด์Šคํ‹ฑ๊ณผ ๋‹ค๋ฅธ์ ์€ ๋„˜์–ด๊ฐ€๋Š” ๊ฒฝ์šฐ๋ฅผ ๋ฐฐ์ œํ•˜๋Š” ๊ฒƒ์ด๋ผ ๊ทธ๋ฆฌ๋””๋กœ ํ’€ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
- 3, 4๋ฒˆ์˜ ์ง€๋ฌธ์„ ์ž์„ธํžˆ ์ฝ์–ด๋ณด์•˜๋‹ค. ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋˜ i์™€ i + 1์˜ ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ , i + 1 ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚จ๋‹ค๋Š” ๊ฒƒ.
- ์ฆ‰, ํ˜„์žฌ ์„ ํƒํ•œ ์ฑ„๋„์„ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.
- ๊ทธ๋ฆฌ๋””ํ•˜๊ฒŒ ํ’€๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ? ๋จผ์ € KBS1์„ ๋งจ ์œ„๋กœ ์˜ฌ๋ฆฌ๋Š” ๊ฒฝ์šฐ๋ฅผ ์ƒ๊ฐํ•ด๋ณด๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- KBS1์ด ๋งจ ์œ„์— ์กด์žฌํ•˜๊ฑฐ๋‚˜, ์•„๋‹ˆ๋ฉด ์•„๋ž˜์— ์กด์žฌํ•  ๊ฒƒ์ด๋‹ค.
- ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ KBS2๊ฐ€ ์กด์žฌํ•˜๋Š” ์œ„์น˜๋ฅผ ํƒ์ƒ‰ํ•˜๊ณ , ๋˜‘๊ฐ™์ด ์ˆ˜ํ–‰ํ•œ๋‹ค.
- ๋งจ ์œ„์˜ ์›์†Œ๋ฅผ ์›€์ง์ด๋Š” ๊ฒฝ์šฐ์™€ KBS1์„ ์ง์ ‘ ์›€์ง์ด๋Š” ๊ฒฝ์šฐ๋ฅผ ๋น„๊ตํ•œ๋‹ค.
- ๊ทธ์ค‘ ์ ๊ฒŒ๊ฑธ๋ฆฌ๋Š” ๊ฒฝ์šฐ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
- ์ŠคํŽ˜์…œ ์ €์ง€๊ฐ€ ์ •๋‹ต์ธ ์ผ€์ด์Šค๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ์ธ ๊ฒฝ์šฐ๋ฅผ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์„ ๊ฒ€์ƒ‰์„ ํ†ตํ•ด์„œ ์•Œ์•˜๋‹ค.
- ์ฒ˜์Œ ์ œ์ถœํ•œ ์ฝ”๋“œ๊ฐ€ ์˜ค๋‹ต์ด ๋˜์—ˆ๋˜ ์ด์œ ๋Š”, KBS2๊ฐ€ KBS1๋ณด๋‹ค ์•ž์— ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ๊ณ ๋ คํ•˜์ง€ ์•Š์•„์„œ ์ƒ๊ธด ๋ฌธ์ œ์˜€๋‹ค.
17. [ATM](https://www.acmicpc.net/problem/11399)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/atm/Main.java)
- ์ •๋ ฌ์„ ์ˆ˜ํ–‰ํ•ด์„œ ๋”ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค.
- 1000๊ฐœ์˜ input์ด๋ฏ€๋กœ, nlogn ์ด๋ผ๋ฉด ์ถฉ๋ถ„ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์ž…๋ ฅ ๊ฐ’์ด overflow๊ฐ€ ๋ฐœ์ƒํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์–ด long ํƒ€์ž…์„ ์จ์ฃผ์—ˆ๋‹ค.
- ์™œ ์ด๊ฒŒ ์‹ค๋ฒ„์ธ์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค.
- ์™œ ์ด๊ฒŒ ๊ทธ๋ฆฌ๋””์ธ์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค. ๊ฐ•์˜๋„ ๋ˆ ์ฃผ๊ณ  ์‚ฌ์•ผํ•˜๊ณ  ใ… ใ… (๋งค ์ˆœ๊ฐ„ ์ตœ์ ์˜ ํ•ด๋ฅผ ๊ตฌํ•˜๋„๋ก ๋งŒ๋“ค์–ด์ค˜์•ผํ•ด์„œ ๊ทธ๋Ÿฐ๊ฑด๊ฐ€?)
- ์˜คํžˆ๋ ค ์ •๋ ฌ์„ ์ƒ๊ฐํ•˜์ง€ ๋ชปํ•˜๋ฉด ๋ชปํ‘ธ๋Š” ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค.
- ํ˜ธ๋ˆ…์Šค์—๊ฒŒ ๋ฌผ์–ด๋ณด์•˜๋Š”๋ฐ, ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋ง ๊ทธ๋Œ€๋กœ ๋ถ€๋ถ„ํ•ด๊ฐ€ ์ตœ์ ํ•ด๊ฐ€ ๋˜๋ฉด ๋˜๋Š”๊ฑฐ๋ผ๊ณ  ํ–ˆ๋‹ค.
18. [๋™์ „ 0](https://www.acmicpc.net/problem/11047)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/coinzero/Main.java)
- ๋™์ „์„ ์—ญ์ˆœ์œผ๋กœ ๋”ํ•ด์„œ ํ•„์š”ํ•œ ๋™์ „ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์งœ์•ผํ•œ๋‹ค.
- ์ƒ๊ฐํ–ˆ๋˜ ๋Œ€๋กœ ๋™์ž‘ํ–ˆ๊ณ  ์‹ค๋ฒ„ 1๊ธ‰์˜ ๋ฌธ์ œ๋Š” ์•„๋‹Œ ๊ฒƒ ๊ฐ™๋‹ค.
19. [ํšŒ์˜์‹ค๋ฐฐ์ •](https://www.acmicpc.net/problem/1931)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/meetingroom/Main.java)
- ์ตœ์ ํ•ด๋ฅผ ๊ตฌํ•˜๋ ค๋ฉด, ๊ฐ€์žฅ ๋จผ์ € ๋๋‚˜๋Š” ๊ฒƒ์„ ์„ ํƒํ•˜๊ณ  ์ด์ „์— ์„ ํƒํ•œ ๊ฒƒ๊ณผ ๊ฒน์น˜์ง€ ์•Š์œผ๋ฉด ๋จ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
- ๋˜ํ•œ ๋ฌธ์ œ์˜ ์กฐ๊ฑด์—์„œ (1,4) (4,7) ๊ฐ™์€ ์กฐ๊ฑด์˜ ๊ฒฝ์šฐ ๊ฐ€๋Šฅํ•จ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
- ์ •๋ ฌ๊ธฐ์ค€์—์„œ ๋๋‚˜๋Š” ์‹œ๊ฐ„์ด ๊ฐ™์€ ๊ฒฝ์šฐ ์ •๋ ฌ๋˜๋Š” ์กฐ๊ฑด์„ ์„ค์ •ํ•ด์ฃผ์ง€ ์•Š์•„์„œ ํ‹€๋ ธ๋‹ค. ์ •๋ ฌํ•  ๋•Œ๋„ ํ•ญ์ƒ ์‹ ๊ฒฝ์จ์„œ ํ•˜์ž.
- Comparator ๋žŒ๋‹ค๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋Š๋ ค์ง„๋‹ค. ํ•ญ์ƒ ์ผ๊ด€์ ์œผ๋กœ ๋น„๊ตํ•  ๋•Œ, Comparable์„ implementํ•˜๋Š” ๊ฒƒ๋„ ๊ณ ๋ คํ•ด๋ณด์ž.
20. [๋กœํ”„](https://www.acmicpc.net/problem/2217)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/rope/Main.java)
- ๋ชจ๋‘ ๊ณ ๋ฅด๊ฒŒ ๋ถ„๋ฐฐ๋œ๋‹ค๋Š” ๊ฒƒ์ด ํ•ต์‹ฌ์ธ ๊ฒƒ ๊ฐ™๋‹ค.
- ์ฆ‰, n๋ถ€ํ„ฐ ์ˆœํšŒํ•˜๋ฉด์„œ ๊ฐ€์žฅ ๋†’์€ ์ค‘๋Ÿ‰์ด ๊ฑธ๋ฆฌ๋Š” ๊ฒฝ์šฐ๋ฅผ ์ฐพ์œผ๋ฉด ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ์ •๋ ฌ์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- n^2 ๊นŒ์ง€ ๊ฐ€๋Šฅํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
21. [30](https://www.acmicpc.net/problem/10610)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/thirty/Main.java)
- ๊ฐ€์žฅ ํฐ ์ˆ˜ ์ด๋ฉด์„œ 30์˜ ๋ฐฐ์ˆ˜๋ฅผ ๋งŒ๋“œ๋Š” ๋ฌธ์ œ
- ์ผ๋‹จ ์ˆ˜๋ฅผ ์ •๋ ฌํ•ด์„œ ํฐ ์ˆ˜๋ฅผ ๋งŒ๋“  ๋‹ค์Œ 30์˜ ๋ฐฐ์ˆ˜์ธ์ง€ ์ฒดํฌ๋ฅผ ํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ์ˆœ์„œ๋ฅผ ๋ฐ”๊ฟจ์„ ๋•Œ, 30์˜ ๋ฐฐ์ˆ˜์ธ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„๊นŒ? ์•„๋งˆ ์—†์œผ๋‹ˆ๊นŒ ๊ทธ๋ฆฌ๋”” ์ผ ๊ฒƒ ๊ฐ™๋‹ค.
- ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๊ฐ€ ๋–ด๋‹ค. ์•„๋งˆ ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๊ณ ๋ คํ•˜์ง€ ์•Š์€ ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ฌธ์ œ๊ฐ€ ๊ฑฐ์ง€๊ฐ™์•˜๋‹ค. 10๋งŒ์ž๋ฆฌ ์ˆ˜ ์˜€๋‹ค. ์ด๊ฑธ Integer.parseInt๋ฅผ ํ•˜๋ ค๊ณ  ํ–ˆ์œผ๋‹ˆ...
- ์งง์€ ์†”๋ฃจ์…˜์„ ๋ณด๋‹ˆ๊นŒ 10๊ฐœ ํฌ๊ธฐ์˜ ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•ด์„œ ๋‚˜์˜จ ๊ฐฏ์ˆ˜๋งŒํผ ํ–ˆ๋‹ค. countsort์˜ ๋ฐฉ์‹์„ ์ฐจ์šฉํ•œ ๋“ฏ ํ•˜๋‹ค.
22. [์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ](https://www.acmicpc.net/problem/1541)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/lostbracket/Main.java)
- ์‹์˜ ๊ฒฐ๊ณผ๋ฅผ ์ตœ์†Œ๋กœ ๋งŒ๋“œ๋Š” ๋ฌธ์ œ๋‹ค.
- ๋”ํ•˜๊ธฐ ๋นผ๊ธฐ ์ด๋ฏ€๋กœ ์—ฐ์‚ฐ์˜ ์ˆœ์„œ๋งŒ ์ƒ๊ฐํ•˜๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ์ˆœ์„œ๋Œ€๋กœ ์ฝ์œผ๋ฉด์„œ -๊ฐ€ ๋“ฑ์žฅํ•˜๋Š” ์ˆœ๊ฐ„๋ถ€ํ„ฐ ๋‹ค์Œ -๊ฐ€ ๋“ฑ์žฅํ•  ๋•Œ ๊นŒ์ง€ ๋ชจ๋‘ ๋”ํ•ด์„œ ๋นผ๋Š” ๊ฒƒ์ด ๋งž์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ทธ๋ƒฅ -๊ฐ€ ๋“ฑ์žฅํ•œ ์ดํ›„๋กœ๋ถ€ํ„ฐ ๋‹ค ๋นผ๋ฒ„๋ฆฌ๋ฉด ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ์™œ๋ƒ๋ฉด -๊ฐ€ ๋“ฑ์žฅํ•œ ์ดํ›„์˜ +๋Š” ๊ด„ํ˜ธ๋กœ ๊ฐ์‹ผ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋ฉด ๋œ๋‹ค.
23. [๋ฌธ์ž์—ด](https://www.acmicpc.net/problem/1120)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/string/Main.java)
- ์ฐจ์ด๋ฅผ ์ตœ์†Œ๋กœ ํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?
- ๋‘˜์ด ๊ฒน์น˜๋Š” ์˜์—ญ์ด ๊ฐ€์žฅ ๋งŽ์€ ๋ถ€๋ถ„์ด ๊ณง ์ตœ์ ์ผ ๊ฒƒ ๊ฐ™๋‹ค.
- A์˜ ์•ž์ด๋‚˜ ๋’ค์— ์—ฐ์‚ฐ์„ ํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๊ฒน์น˜๋Š” ์˜์—ญ์˜ ๊ฐœ์ˆ˜๋งŒ ์ฒดํฌํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
- ์•ž์—์„œ๋ถ€ํ„ฐ ํƒ์ƒ‰ํ•˜๊ณ  ๋’ค์—์„œ๋ถ€ํ„ฐ ํƒ์ƒ‰ํ•ด์„œ ๋‘˜์ค‘์— ๋” ์ ๊ฒŒ ์ฐจ์ด๋‚˜๋Š” ๊ฒƒ์„ ์„ ํƒํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ์•ž ๋’ค๋งŒ ์„ ํƒํ•˜๋ฉด ์•ˆ๋˜๊ณ , ์ฐจ์ด๋‚˜๋Š” ๊ตฌ๊ฐ„ ์ „์ฒด๋ฅผ ํƒ์ƒ‰ํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
24. [์‹ ์ž… ์‚ฌ์›]https://www.acmicpc.net/problem/1946)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/baekjoon/newrecruits/Main.java)
- ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์„œ ํ’€๋ฉด ๋ณด๋‹ค ์‰ฝ๊ฒŒ ํ’€๋ฆด ๊ฒƒ ๊ฐ™์€ ๋ฌธ์ œ๋‹ค.
- ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ •๋ ฌ์„ ํ•˜๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ์ ์–ด๋„ ํ•˜๋‚˜๊ฐ€ ๋‹ค๋ฅธ ์ง€์›์ž๋ณด๋‹ค ๋–จ์–ด์ง€์ง€ ์•Š๋Š” ์ž(๋‘˜ ๋‹ค ๋ˆ„๊ตฐ๊ฐ€๋ณด๋‹ค ๋ถ€์กฑํ•˜๋‹ค๋ฉด ํƒˆ๋ฝ๋Œ€์ƒ)
- ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์ง€ ์•Š๊ณ  CountSort ํ’€์ดํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์ข€ ์‹ ๊ธฐํ•ด์„œ ๋”ฐ๋ผํ•ด๋ด์•ผ๊ฒ ๋‹ค.

## ์ข…๋งŒ๋ถ

1. [๋ก ํŽ˜์Šคํ‹ฐ๋ฒŒ](https://algospot.com/judge/problem/read/FESTIVAL)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/jongmanbook/festival/Main.java)
- ์ผ๋‹จ ๋ฌด์‹ํ•˜๊ฒŒ ํ’€์–ด๋ณด์•˜๋‹ค. ๋‹น์—ฐํžˆ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋‚ฌ๋‹ค.๐Ÿ˜ญ
- n^3์„ n^2์ด๋ผ๋„ ์ค„์—ฌ๋ณด๊ณ  ์‹ถ์–ด์„œ, ์ฐพ์•„๋ณด์•˜๋‹ค. Prefix Sum์„ ์ด์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์•„์„œ ์ ์šฉํ–ˆ์—ˆ๋‹ค.
- ๊ทผ๋ฐ ์˜ค๋‹ต์ด๋‹ค. ๋” ๊ณ ๋ฏผํ•ด๋ด์•ผ๊ฒ ๋‹ค.

---

## ์ƒ๊ฐํ•ด๋ณด๊ธฐ

1. ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์— ์ค‘๋ณต๋œ ๋ฌธ์ž๊ฐ€ ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒ€์‚ฌํ•˜๋Š” ํ•จ์ˆ˜
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/overlapchar/Solution.java)
2. ๋ฒ„๋ธ” ์ •๋ ฌ, ์‚ฝ์ž… ์ •๋ ฌ, ํ€ต ์ •๋ ฌ, ๋จธ์ง€ ์ •๋ ฌ, ํž™ ์ •๋ ฌ์„ ์ง์ ‘ ๊ตฌํ˜„ํ•ด ๋ณด์ž
- [๋ฒ„๋ธ” ์ •๋ ฌ](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/BubbleSort.javahttps://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/BubbleSort.java)
- [์‚ฝ์ž… ์ •๋ ฌ](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/SelectionSort.java)
- [ํ€ต ์ •๋ ฌ](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/QuickSort.java)
- [๋ฒ„๋ธ” ์ •๋ ฌ(๋‹จ์ผ ๋ฐฐ์—ด)](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/MergeSortInPlace.java)
- [๋ฒ„๋ธ” ์ •๋ ฌ](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/sorting/MergeSort.java)
3. ์œ„ ์ •๋ ฌ์˜ ์žฅ๋‹จ์ ๊ณผ ๋ณต์žก๋„์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž
4. count sort์™€ radix sort์˜ ์ฝ”๋“œ๋ฅผ ์ดํ•ดํ•ด๋ณด๊ณ  ์žฅ์ ์€ ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณด์ž
5. ํ•ด์‹œ์— ๋Œ€ํ•ด ๋” ๊ณต๋ถ€ํ•ด๋ณด์ž
6. ์ด์ง„ ํŠธ๋ฆฌ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ํ•™์Šตํ•œ๋‹ค.
7. ์ด์ง„ ๊ฒ€์ƒ‰ํŠธ๋ฆฌ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ํ•™์Šตํ•œ๋‹ค.
8. ํŠธ๋ฆฌ์˜ ์ˆœํšŒ์— ๋Œ€ํ•ด ํ•™์Šตํ•œ๋‹ค.
9. ํž™์ด ๋ฌด์—‡์ธ์ง€์™€ ํž™ ์ •๋ ฌ์— ๋Œ€ํ•ด ํ•™์Šตํ•œ๋‹ค.
10. ์ด์ง„ ํƒ์ƒ‰์„ ๊ตฌํ˜„ํ•ด๋ณธ๋‹ค.
- [์ด์ง„ ํƒ์ƒ‰](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/search/BinarySearch.java)
- ์žฌ๊ท€์ ์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณธ๋‹ค.
- ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณธ๋‹ค.
11. ์žฌ๊ท€ ๊ณต๋ถ€
- [์ž…๋ ฅ๋œ ๋ฐฐ์—ด์˜ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ์žฌ๊ท€ํ•จ์ˆ˜](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/recursion/ArraySum.java)
์žฌ๊ท€์ ์œผ๋กœ ์ƒ๊ฐํ•˜๊ธฐ๊ฐ€ ์‰ฝ์ง€๊ฐ€ ์•Š์•˜๋‹ค..! ์žฌ๊ท€์— ๋Œ€ํ•œ ์—ฐ์Šต์„ ๋งŽ์ด ํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.
๊ผฌ๋ฆฌ ์žฌ๊ท€๋กœ ๋ฐ”๊พธ์–ด ๋ณด์•˜๋‹ค!
- [์ž…๋ ฅ๋œ ๋ฆฌ์ŠคํŠธ์˜ ์›์†Œ์˜ ๊ฐฏ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ์žฌ๊ท€ํ•จ์ˆ˜](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/recursion/ListCount.java)
๊ผฌ๋ฆฌ์žฌ๊ท€๋กœ ํ•ด๊ฒฐํ•ด๋ณด์•˜๋‹ค!
- [์ž…๋ ฅ๋œ ๋ฆฌ์ŠคํŠธ์˜ ๊ฐ€์žฅ ํฐ ์ˆ˜๋ฅผ ์ฐพ๋Š” ์žฌ๊ท€ํ•จ์ˆ˜](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/recursion/LargestNumber.java)
- [ํŒฉํ† ๋ฆฌ์–ผ์„ ๊ตฌํ•˜๋Š” ์žฌ๊ท€ํ•จ์ˆ˜](https://github.com/ksundong/algorithm-solution/blob/master/src/main/java/dev/idion/thinking/recursion/Factorial.java)
๊ผฌ๋ฆฌ์žฌ๊ท€๋กœ ํ•ด๊ฒฐํ•ด๋ณด์•˜๋‹ค!

---

## SQL

### [ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค](https://programmers.co.kr)

1. [์ตœ๋Œ“๊ฐ’ ๊ตฌํ•˜๊ธฐ](https://programmers.co.kr/learn/courses/30/lessons/59415)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/src/main/resources/sql/programmers/maximum-value/maximum.sql)
- ์˜ˆ์ œ์˜ ์ •๋‹ต ๋ถ€๋ถ„์ด Alias๋ฅผ ์ด์šฉํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์•„์„œ Alias๋ฅผ ์ด์šฉํ–ˆ๋‹ค.
- ํ•˜๋‚˜์˜ ๊ฒฐ๊ณผ๋งŒ ์š”๊ตฌํ•˜๋ฏ€๋กœ LIMIT์„ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ–ˆ๋‹ค.
- ๊ฐ€์žฅ ์ตœ๊ทผ์ด๋ผ๊ณ  ํ•˜์˜€์œผ๋ฏ€๋กœ, DATETIME์˜ ORDER BY๋ฅผ ์ด์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์•˜๋‹ค.
- ๋ฌธ์ œ์˜ ์˜๋„๋ฅผ ์ตœ๋Œ€ํ•œ ๋ฐ˜์˜ํ•ด์„œ ์ฟผ๋ฆฌ๋ฅผ ๋” ์ค„์˜€๋‹ค.

---

## Python

### [LeetCode](https://leetcode.com/)

1. [125. Valid Palindrome](https://leetcode.com/problems/valid-palindrome/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/valid_palindrome/Solution.py)
- ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์ด ํŒฐ๋ฆฐ๋“œ๋กฌ์ด์ง€ ํ™•์ธํ•˜๋ผ. ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์˜๋ฌธ์ž์™€ ์ˆซ์ž๋งŒ์„ ๋Œ€์ƒ์œผ๋กœ ํ•œ๋‹ค.
- ์†Œ๋ฌธ์ž๋กœ ๋งŒ๋“ค๊ณ  ์žˆ๋Š” ๊ฐœ์ˆ˜๋ฅผ ๊ฐ€์ง€๊ณ  ํŒ๋‹จํ•˜๋„๋ก ๋งŒ๋“ค์—ˆ๋Š”๋ฐ, ์ค‘๊ฐ„์— ์žˆ๋Š” ๊ฒƒ ๋•Œ๋ฌธ์— ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.
- ์นด์šดํ„ฐ๋ฅผ ์“ฐ๋ฉด ์•ˆ๋œ๋‹ค. ์ƒ๊ฐํ•ด๋ณด๋‹ˆ๊นŒ ์•ž๊ณผ ๋’ค๋ฅผ ๋™์‹œ์— ํ™•์ธํ•ด์•ผํ•˜๋Š”๋ฐ... ํ ...
- ์Šฌ๋ผ์ด์‹ฑ์„ ํ™œ์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
2. [344. Reverse String](https://leetcode.com/problems/reverse-string/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/reverse_string/Solution.py)
- ๋ฌธ์ž์—ด์„ ๋’ค์ง‘๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜๋ผ. ์ž…๋ ฅ๊ฐ’์€ ๋ฌธ์ž ๋ฐฐ์—ด์ด๋ฉฐ, ๋ฆฌํ„ด ์—†์ด ๋ฆฌ์ŠคํŠธ ๋‚ด๋ถ€๋ฅผ ์ง์ ‘ ์กฐ์ž‘ํ•˜๋ผ.
- ํŒŒ์ด์ฌ์€ ๋ฌธ์ž์—ด์ž์ฒด๋ฅผ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅ ํ•ด์„œ ๋ฆฌ์ŠคํŠธ๋กœ ์ค€ ๊ฒƒ ๊ฐ™๋‹ค.
- ์Šค์™‘ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค๋ฉด ๋ ๊นŒ?
3. [937. Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/reorder_log_files/Solution.py)
- ๋กœ๊ทธ๋ฅผ ์žฌ์ •๋ ฌํ•˜๋ผ. ๊ธฐ์ค€์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ๋ชจ๋“  ๋กœ๊ทธ๋Š” ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„๋œ ๋‹จ์–ด๋“ค๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.
1. ๋กœ๊ทธ์˜ ๊ฐ€์žฅ ์•ž ๋ถ€๋ถ„์˜ ๋‹จ์–ด๋Š” ์‹๋ณ„์ž๋‹ค.
2. ๋ฌธ์ž๋กœ ๊ตฌ์„ฑ๋œ ๋กœ๊ทธ(let)๊ฐ€ ์ˆซ์ž ๋กœ๊ทธ(dig)๋ณด๋‹ค ์•ž์— ์˜จ๋‹ค.
3. ์‹๋ณ„์ž๋Š” ์ˆœ์„œ์— ์˜ํ–ฅ์„ ๋ผ์น˜์ง€ ์•Š์ง€๋งŒ, ๋ฌธ์ž๊ฐ€ ๋™์ผํ•œ ๊ฒฝ์šฐ ์‹๋ณ„์ž ์ˆœ์œผ๋กœ ํ•œ๋‹ค.
4. ์ˆซ์ž ๋กœ๊ทธ๋Š” ์ž…๋ ฅ ์ˆœ์„œ๋Œ€๋กœ ํ•œ๋‹ค.
- ๋ฌธ์ œ๋ฅผ ์ดํ•ดํ•˜๋Š”๋ฐ ์ข€ ์‹œ๊ฐ„์ด ๊ฑธ๋ ธ๋‹ค.
- ๋ฌธ์ž(let) ๋กœ๊ทธ๊ฐ€ ๋จผ์ €์˜ค๋ฉฐ, ๋‹จ์–ด์˜ ์‚ฌ์ „์ˆœ์œผ๋กœ ์ •๋ ฌ๋˜๊ณ , ๋‹จ์–ด๊ฐ€ ๋‹ค ๋˜‘๊ฐ™์€ ๊ฒฝ์šฐ ์‹๋ณ„์ž ๋’ค์˜ ์ˆซ์ž๋กœ ์ •๋ ฌํ•œ๋‹ค.
- ์ˆซ์ž๋กœ๊ทธ๋Š” ์›๋ž˜ ์ˆœ์„œ๋ฅผ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•ด์„œ ์ •๋ ฌํ•œ๋‹ค.
- ํŒŒ์ด์ฌ์˜ ์ •๋ ฌ๋ฐฉ์‹์„ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค. ๊ทธ๋ž˜์„œ ๋‹ต์„ ์ฐธ๊ณ ํ–ˆ๋‹ค.
- ๋ฆฌ์ŠคํŠธ ์ปดํ”„๋ฆฌํ—จ์…˜์„ ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค.
4. [819. Most Common Word](https://leetcode.com/problems/most-common-word/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/most_common_word/Solution.py)
- ๊ธˆ์ง€๋œ ๋‹จ์–ด๋ฅผ ์ œ์™ธํ•œ ๊ฐ€์žฅ ํ”ํ•˜๊ฒŒ ๋“ฑ์žฅํ•˜๋Š” ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•˜๋ผ.
- ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„์„ ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ๊ตฌ๋‘์  ๋˜ํ•œ ๋ฌด์‹œํ•œ๋‹ค.
- Counter๋ฅผ ํ™œ์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- List Comprehension์œผ๋กœ ban๋œ ๋‹จ์–ด๋ฅผ ์ œ์™ธํ•˜๋Š” ๊ฒƒ์ด ๋‚˜์„ ๊ฒƒ ๊ฐ™๋‹ค.
5. [49. Group Anagrams](https://leetcode.com/problems/group-anagrams/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/group_anagrams/Solution.py)
- ๋ฌธ์ž์—ด ๋ฐฐ์—ด์„ ๋ฐ›์•„ ์• ๋„ˆ๊ทธ๋žจ ๋‹จ์œ„๋กœ ๊ทธ๋ฃนํ•‘ํ•˜๋ผ.
- ๊ฐ™์€ ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋Š” ๋ฌธ์ž์—ด๋ผ๋ฆฌ ๊ทธ๋ฃนํ•‘ํ•˜๋Š” ๋ฌธ์ œ๋‹ค.
- ์ถœ๋ ฅ์˜ ์ˆœ์„œ๋Š” ๋ฌด๊ด€ํ•˜๋‹ค.
- char ๊ฐ’์˜ ํ•ฉ์„ ๋”ํ•ด์„œ map์— ๋Œ€ํ•œ key๋กœ ํ•˜๊ณ , ๊ฐ™์€ key๋ฅผ list๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์€ ์–ด๋–จ๊นŒ?
- ์•„์Šคํ‚ค ์ฝ”๋“œ์˜ ํ•ฉ์ด ๊ฐ™์€ ๊ฒฝ์šฐ๊ฐ€ edge case์˜€๋‹ค.
- ์ •๋ ฌ์„ ํ•ด์ค˜์•ผ ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
6. [5. Longest Palindrome Substring](https://leetcode.com/problems/longest-palindromic-substring/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/longest_palindromic_substring/Solution.py)
- ๊ฐ€์žฅ ๊ธด ํŒฐ๋ฆฐ๋“œ๋กฌ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•˜๋ผ.
- ์–ด๋–ป๊ฒŒ ์ ‘๊ทผํ•ด์•ผ ํ• ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค. ์ผ๋‹จ ํŒจ์Šค
7. [1. Two sum](https://leetcode.com/problems/two-sum/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/two_sum/Solution.py)
- ๋ง์…ˆํ•˜์—ฌ ํƒ€๊ฒŸ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ฐฐ์—ด์˜ ๋‘ ์ˆซ์ž ์ธ๋ฑ์Šค๋ฅผ ๋ฆฌํ„ดํ•˜๋ผ
- ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ ๋ธŒ๋ฃจํŠธ ํฌ์Šค๊ฐ€ ์žˆ์ง€๋งŒ, ๋งค์šฐ ๋Š๋ฆด ๊ฒƒ์ด๋‹ค.
- ๋”•์…”๋„ˆ๋ฆฌ๋ฅผ ์“ฐ๋Š” ํŽธ์ด ๊ฐ€์žฅ ๋น ๋ฅผ ๊ฒƒ ๊ฐ™๋‹ค.
8. [42. Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/trapping_rain_water/Solution.py)
- ๋†’์ด๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋น„ ์˜จ ํ›„ ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ๋ฌผ์ด ์Œ“์ผ ์ˆ˜ ์žˆ๋Š”์ง€ ๊ณ„์‚ฐํ•˜๋ผ.
- ๋‹จ์ˆœํžˆ ๋‘ ์ˆ˜์˜ ์ฐจ๋งŒ ๊ณ„์‚ฐํ•ด์„  ์•ˆ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ์ˆœ์ฐจ๋กœ ํƒ์ƒ‰ํ•˜๋ฉฐ ํˆฌ ํฌ์ธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•ด๋ด์•ผ๊ฒ ๋‹ค.
- ๋ฌธ์ œ๊ฐ€ ์ตœ๊ณ  ๋†’์ด์— ๋„๋‹ฌํ–ˆ์„ ๋•Œ, ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค.
- ์ผ๋‹จ ํŒจ์Šค
9. [15. 3Sum](https://leetcode.com/problems/3sum/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/3sum/Solution.py)
- ๋ฐฐ์—ด์„ ์ž…๋ ฅ๋ฐ›์•„ ํ•ฉ์œผ๋กœ 0์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” 3๊ฐœ์˜ ์—˜๋ฆฌ๋จผํŠธ๋ฅผ ์ถœ๋ ฅํ•˜๋ผ.
- ๋ธŒ๋ฃจํŠธ ํฌ์Šค๋Š” ๊ณ ๋ คํ•˜์ง€ ๋ง์ž...
- ํ•˜๋‚˜๋ฅผ ์ •ํ•ด๋†“๊ณ  Two sum ๋ฌธ์ œ๋กœ ๋งŒ๋“ค์–ด์•ผ ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- ํ’€์ด ์‹คํŒจ
10. [561. Array Partition I](https://leetcode.com/problems/array-partition-i/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/array-partition-i/Solution.py)
- n๊ฐœ์˜ ํŽ˜์–ด๋ฅผ ์ด์šฉํ•œ min(a, b)์˜ ํ•ฉ์œผ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฐ€์žฅ ํฐ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋ผ.
- ์ •๋ ฌ์„ ํ•ด์„œ ํ•ฉ์„ ๊ตฌํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ์•ฝ๊ฐ„ ๊ทธ๋ฆฌ๋””ํ•œ ํ’€์ด์ธ ๊ฒƒ ๊ฐ™๋‹ค.
11. [238. Produc of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/product_of_array_except_self/Solution.py)
- ๋ฐฐ์—ด์„ ์ž…๋ ฅ๋ฐ›์•„ output[i] ๊ฐ€ ์ž์‹ ์„ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ๋ชจ๋“  ์š”์†Œ์˜ ๊ณฑ์…ˆ ๊ฒฐ๊ณผ๊ฐ€ ๋˜๋„๋ก ์ถœ๋ ฅํ•˜๋ผ.
- ์ œ์•ฝ์กฐ๊ฑด์ด ๋‚˜๋ˆ—์…ˆ์„ ํ•˜์ง€ ๋ง๋ผ๋Š” ๊ฒƒ์ด ์žˆ๋‹ค. ๋‚˜๋ˆ—์…ˆ์„ ํ•˜๋Š” ๊ฒƒ์„ ์ƒ๊ฐํ–ˆ๋Š”๋ฐ...
- ์ „์ฒดํ•ฉ์œผ๋กœ ๋‚˜๋ˆ„๋Š”๊ฒŒ ์‰ฌ์šฐ๋‹ˆ๊นŒ ์ด๋Ÿฐ ์ œ์•ฝ์กฐ๊ฑด์„ ์ค€ ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ธŒ๋ฃจํŠธ ํฌ์Šค๋กœ ์‹œ๋„ํ•ด๋ณด์ž
- ์—ญ์‹œ ์‹œ๊ฐ„์ดˆ๊ณผ๋กœ ์‹คํŒจํ–ˆ๋‹ค.
- ์†”๋ฃจ์…˜์„ ๋ณด๋‹ˆ ์™ผ์ชฝ ๊ณฑ์— ์˜ค๋ฅธ์ชฝ ๋ถ€ํ„ฐ ๊ณฑ์„ ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ‘ผ๋‹ค๊ณ  ํ•œ๋‹ค.
12. [121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/best_time_to_buy_and_sell_stock/Solution.py)
- ํ•œ ๋ฒˆ์˜ ๊ฑฐ๋ž˜๋กœ ๋‚ผ ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ์ด์ต์„ ์‚ฐ์ถœํ•˜๋ผ.
- ์ •๋ ฌ์€ ํ•  ์ˆ˜ ์—†๋‹ค.
- ์‹œ์ž‘๊ฐ’์€ 0์œผ๋กœ ๋‘์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ๋งค์šฐ ๋Š๋ ธ๋‹ค. ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์„ ๊ณ ๋ฏผํ•ด๋ด์•ผ๊ฒ ๋‹ค.
- O(n) ํ’€์ด list slice๋ฅผ ํ•˜์ง€ ์•Š๊ณ , ์ฒ˜์Œ๋ถ€ํ„ฐ ์ตœ๋Œ€ ์ด์ต๊ณผ ์ตœ์†Œ ๊ฐ€๊ฒฉ์„ ๊ฐฑ์‹ ํ•ด๋‚˜๊ฐ„๋‹ค.
13. [234. Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/palindrome_linked_list/Solution.py)
- ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๊ฐ€ ํŒฐ๋ฆฐ๋“œ๋กฌ ๊ตฌ์กฐ์ธ์ง€ ํŒ๋ณ„ํ•˜๋ผ.
- deque๋กœ ๋งŒ๋“ค์–ด์„œ ์•ž ๋’ค๋ฅผ popํ•ด์„œ ๋น„๊ตํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ํŒฐ๋ฆฐ๋“œ๋กฌ์€ deque๋ฅผ ํ™œ์šฉํ•˜๊ธฐ!
- ์ฑ…์„ ๋ณด๋‹ˆ ๋Ÿฐ๋„ˆ๋ฅผ ์ด์šฉํ•œ ํ’€์ด๊ฐ€ ์žˆ์—ˆ๋‹ค.
14. [21. Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/merge_two_sorted_lists/Solution.py)
- ์ •๋ ฌ๋˜์–ด ์žˆ๋Š” ๋‘ ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๋ฅผ ํ•ฉ์ณ๋ผ.
- ์ƒˆ๋กœ์šด ๋…ธ๋“œ๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ถ™์—ฌ๋‚˜๊ฐ€๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ์ •๋ ฌ์ด ๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋น„๊ต๋ฅผ ํ•ด๋‚˜๊ฐ€๋ฉด์„œ ๋ถ™์ด๋ฉด ๋œ๋‹ค.
- ๋…ธ๋“œ๋Š” ์ดˆ๊ธฐ๊ฐ’์ด 0์ด๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฅผ ์ ์ ˆํžˆ ์ด์šฉํ•ด์•ผํ•œ๋‹ค.
- ๋”๋ฏธ๋…ธ๋“œ๋Š” ๋ฐ˜ํ™˜ํ•˜๋ฉด ์•ˆ๋˜๋ฏ€๋กœ next๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
15. [206. Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/reverse_linked_list/Solution.py)
- ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋’ค์ง‘์–ด๋ผ.
- ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ๋„ ๊ตฌํ˜„์ด ๊ฐ€๋Šฅํ•˜๊ณ , ์žฌ๊ท€๋กœ๋„ ๊ตฌํ˜„์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
- ๋ฐ˜๋ณต์œผ๋กœ ๊ตฌํ˜„ํ•  ๋•Œ, ์ฃผ์˜ํ•  ์ ์€ ๋‹ค์ค‘ํ• ๋‹น์„ ์ด์šฉํ•ด์•ผ ํ’€๋ฆฐ๋‹ค๋Š” ์ ์ด๋‹ค.
- ์žฌ๊ท€๋Š” ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ„๋‹ค...
16. [2. Add Two Numbers](https://leetcode.com/problems/add-two-numbers/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode//Solution.py)
- ์—ญ์ˆœ์œผ๋กœ ์ €์žฅ๋œ ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ์˜ ์ˆซ์ž๋ฅผ ๋”ํ•˜๋ผ.
- ๋นˆ ๋ฆฌ์ŠคํŠธ๋Š” ์ฃผ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค.
- ์–‘์ˆ˜๋งŒ ์ฃผ์–ด์ง„๋‹ค.
- ๋…ธ๋“œ๋Š” ๋‹จ ํ•œ ๊ฐœ์˜ ์ˆซ์ž๋งŒ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
- 10์˜ ๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•ด์„œ ์ €์žฅํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค. ์•„๋‹ˆ๋„ค... ์•ž์ž๋ฆฌ์— ๋ถ™์—ฌ์ค˜์•ผ ํ•˜๋„ค...
- ๋”ํ•ด์„œ ์—ญ์ˆœ ์ •๋ ฌํ•˜๊ฑฐ๋‚˜, ์—ญ์ˆœ ์ •๋ ฌ์„ ํ•˜๋ฉด์„œ ๋”ํ•˜๋ฉด ๋˜๊ฒ ์ง€?
- ํ†ต๊ณผ๋Š” ํ–ˆ๋Š”๋ฐ ๋„ˆ๋ฌด ๋Š๋ฆฌ๋‹ค ใ… ใ… ..
- ์ฑ…์—์„  ์ „๊ฐ€์‚ฐ๊ธฐ๋ฅผ ์‘์šฉํ•˜์—ฌ ํ’€์ด๋ฅผ ์ง„ํ–‰ํ–ˆ๋‹ค. ๊น”๋”ํ•˜๊ฒŒ ํ’€๋ ธ๋‹ค.
17. [24. Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/swap_nodes_in_pairs/Solution.py)
- ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ ํŽ˜์–ด(pair)๋‹จ์œ„๋กœ ์Šค์™‘ํ•˜๋ผ.
- ๋…ธ๋“œ๋ฅผ ๋‘ ๊ฐœ์”ฉ ๊ฑด๋„ˆ ๋›ฐ๋ฉด์„œ ๊ฐ๊ฐ์„ ์Šค์™‘ํ•˜๊ฒŒํ•˜๋ฉด ๋˜์ง€ ์•Š์„๊นŒ?
- ์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋งจ ๋ฐ‘์—์„œ๋ถ€ํ„ฐ ๋ณ€๊ฒฝ๋จ์„ ํšจ๊ณผ์ ์œผ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ฒฐ๊ตญ ๋ชปํ’€์—ˆ๋‹ค. ใ… ใ… 
18. [328. Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/odd_even_linked_list/Solution.py)
- ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๋ฅผ ํ™€์ˆ˜ ๋…ธ๋“œ ๋‹ค์Œ์— ์ง์ˆ˜ ๋…ธ๋“œ๊ฐ€ ์˜ค๋„๋ก ์žฌ๊ตฌ์„ฑํ•˜๋ผ. ๊ณต๊ฐ„ ๋ณต์žก๋„ O(1), ์‹œ๊ฐ„ ๋ณต์žก๋„ O(n)์— ํ’€์ดํ•˜๋ผ.
- ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์šฐ์•„ํ•˜๊ฒŒ ํ’€์ดํ•  ์ˆ˜ ์žˆ์„๊นŒ? ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๊ฐ€๋ฉฐ ํ’€์–ด๋ด์•ผ๊ฒ ๋‹ค.
- ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๊ฐ€๋ฉด์„œ ํ’€์—ˆ๋Š”๋ฐ 30๋ถ„ ์ •๋„ ๊ฑธ๋ ธ๋‹ค. ํ›„...
19. [92. Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/reverse_linked_list_ii/Solution.py)
- ์ธ๋ฑ์Šค m์—์„œ n๊นŒ์ง€๋ฅผ ์—ญ์ˆœ์œผ๋กœ ๋งŒ๋“ค์–ด๋ผ. ์ธ๋ฑ์Šค m์€ 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.
- ์—ญ์‹œ ๊ทธ๋ฆผ์„ ๊ทธ๋ ค์„œ ์ฝ”๋“œ๋ฅผ ๋Œ€์ถฉ ์ƒ๊ฐํ•ด๋ณด์•˜๋‹ค.
- ์กฐ๊ฑด์— ๋”ฐ๋ผ์„œ ๋นˆ ๋…ธ๋“œ๊ฐ€ ๋“ค์–ด์˜ฌ ์ผ์€ ์—†์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๊ฐ€๋ฉด์„œ ํ‘ธ๋‹ˆ๊นŒ ํ™•์‹คํžˆ ์ž˜ ํ’€๋ฆฌ๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
20. [20. Valid Parentheses](https://leetcode.com/problems/valid-parentheses/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/valid_parentheses/Solution.py)
- ๊ด„ํ˜ธ๋กœ ๋œ ์ž…๋ ฅ๊ฐ’์ด ์˜ฌ๋ฐ”๋ฅธ์ง€ ํŒ๋ณ„ํ•˜๋ผ.
- ์Šคํƒ์„ ํ™œ์šฉํ•˜๋Š” ์ „ํ˜•์ ์ธ ๋ฌธ์ œ์˜€๋‹ค.
- ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š์•˜๋”๋‹ˆ ์‹คํŒจ๋ฅผ ๋งŽ์ดํ–ˆ๋‹ค.
- ์ง‘์ค‘๋ ฅ์ด ๋‚ฎ์•˜๋‹ค.
21. [316. Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters/)
- ์–ด๋ ค์šด ๋ฌธ์ œ๋ผ ์ผ๋‹จ ํŒจ์Šค
22. [739. Daily Temperatures](https://leetcode.com/problems/daily-temperatures/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/daily_temperatures/Solution.py)
- ๋งค์ผ์˜ ํ™”์”จ ์˜จ๋„ ๋ฆฌ์ŠคํŠธ T๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ, ๋” ๋”ฐ๋œปํ•œ ๋‚ ์”จ๋ฅผ ์œ„ํ•ด์„œ๋Š” ๋ฉฐ์น ์„ ๋” ๊ธฐ๋‹ค๋ ค์•ผ ํ•˜๋Š”์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋ผ.
- ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๊ฐ€๋ฉด์„œ ์ž‘์„ฑํ•˜๋ฉด ๋” ์ž˜๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ์–ธ์ œ ์Šคํƒ์—์„œ ๋นผ๊ณ , ๋„ฃ๋Š”์ง€๋ฅผ ๋ช…ํ™•ํžˆ ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ์ธ๋ฑ์Šค์˜ ์ฐจ์ด๊ฐ€ ์ผ ์ˆ˜๊ฐ€ ๋  ๊ฒƒ ๊ฐ™๋‹ค.
23. [225. Implement Stack Using Queues](https://leetcode.com/problems/implement-stack-using-queues/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/implement_stack_using_queues/Solution.py)
- ํ๋ฅผ ์ด์šฉํ•ด ๋‹ค์Œ ์—ฐ์‚ฐ์„ ์ง€์›ํ•˜๋Š” ์Šคํƒ์„ ๊ตฌํ˜„ํ•˜๋ผ.
- push(x): ์š”์†Œ x๋ฅผ ์Šคํƒ์— ์‚ฝ์ž…ํ•œ๋‹ค.
- pop(): ์Šคํƒ์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
- top(): ์Šคํƒ์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ฅผ ๊ฐ€์ ธ์˜จ๋‹ค.
- empty(): ์Šคํƒ์ด ๋น„์–ด ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- ํŒŒ์ด์ฌ์ด ๋„ˆ๋ฌด ๊ฐ•๋ ฅํ•ด์„œ ์˜คํžˆ๋ ค ๋” ์–ด๋ ค์šด ๋ฌธ์ œ์˜€๋‹ค.
24. [232. Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/implement_queue_using_stacks/Solution.py)
- ์Šคํƒ์„ ์ด์šฉํ•ด ๋‹ค์Œ ์—ฐ์‚ฐ์„ ์ง€์›ํ•˜๋Š” ํ๋ฅผ ๊ตฌํ˜„ํ•˜๋ผ.
- push(x): ์š”์†Œ x๋ฅผ ํ ๋งˆ์ง€๋ง‰์— ์‚ฝ์ž…ํ•œ๋‹ค.
- pop(): ํ ์ฒ˜์Œ์— ์žˆ๋Š” ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค.
- peek(): ํ ์ฒ˜์Œ์— ์žˆ๋Š” ์š”์†Œ๋ฅผ ์กฐํšŒํ•œ๋‹ค.
- empty(): ํ๊ฐ€ ๋น„์–ด์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- ์•ž์˜ ๋ฌธ์ œ๋ž‘ ๋˜‘๊ฐ™์ด ํ’€๋ฉด ์•ˆํ’€๋ฆฐ๋‹ค.
25. [622. Design Circular Queue](https://leetcode.com/problems/design-circular-queue/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/design_circular_queue/Solution.py)
- ์›ํ˜• ํ๋ฅผ ๋””์ž์ธํ•˜๋ผ.
- ์ƒ๊ฐ๋งŒํผ ์‰ฝ๊ฒŒ ํ’€๋ฆฌ์ง€ ์•Š๋Š”๋‹ค. ์ผ๋‹จ ํŒŒ์ด์ฌ์—” ๋ฐฐ์—ด์ด ์—†๋‹ค...
- ๋ฐฐ์—ด์ฒ˜๋Ÿผ ํ•˜๊ธฐ๊ฐ€ ๊นŒ๋‹ค๋กœ์› ๋‹ค.
- -1์„ ๋ฆฌํ„ดํ•  ๋•Œ, if else ๋ฌธ์„ ์“ธ ์ˆ˜ ์žˆ๋Š”๊ฑด ์‹ ๊ธฐํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
26. [641. Design Circular Dequeue](https://leetcode.com/problems/design-circular-deque/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/design_circular_deque/Solution.py)
- ๋‹ค์Œ ์—ฐ์‚ฐ์„ ์ œ๊ณตํ•˜๋Š” ์›ํ˜• ๋ฐํฌ๋ฅผ ๋””์ž์ธํ•˜๋ผ.
- `MyCircularDeque(k)`: ๋ฐํฌ ์‚ฌ์ด์ฆˆ๋ฅผ k๋กœ ์ง€์ •ํ•˜๋Š” ์ƒ์„ฑ์ž๋‹ค.
- `insertFront()`: ๋ฐํฌ ์ฒ˜์Œ์— ์•„์ดํ…œ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์„ฑ๊ณตํ•  ๊ฒฝ์šฐ True๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- `insertLast()`: ๋ฐํฌ ๋งˆ์ง€๋ง‰์— ์•„์ดํ…œ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์„ฑ๊ณตํ•  ๊ฒฝ์šฐ True๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- `deleteFront()`: ๋ฐํฌ ์ฒ˜์Œ์— ์•„์ดํ…œ์„ ์‚ญ์ œํ•˜๊ณ  ์„ฑ๊ณตํ•  ๊ฒฝ์šฐ True๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- `deleteLast()`: ๋ฐํฌ ๋งˆ์ง€๋ง‰์— ์•„์ดํ…œ์„ ์‚ญ์ œํ•˜๊ณ  ์„ฑ๊ณตํ•  ๊ฒฝ์šฐ True๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.
- `getFront()`: ๋ฐํฌ์˜ ์ฒซ ๋ฒˆ์งธ ์•„์ดํ…œ์„ ๊ฐ€์ ธ์˜จ๋‹ค. ๋ฐํฌ๊ฐ€ ๋น„์–ด ์žˆ๋‹ค๋ฉด -1์„ ๋ฆฌํ„ดํ•œ๋‹ค.
- `getRear()`: ๋ฐํฌ์˜ ๋งˆ์ง€๋ง‰ ์•„์ดํ…œ์„ ๊ฐ€์ ธ์˜จ๋‹ค. ๋ฐํฌ๊ฐ€ ๋น„์–ด ์žˆ๋‹ค๋ฉด -1์„ ๋ฆฌํ„ดํ•œ๋‹ค.
- `isEmpty()`: ๋ฐํฌ๊ฐ€ ๋น„์–ด ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ํŒ๋ณ„ํ•œ๋‹ค.
- `isFull()`: ๋ฐํฌ๊ฐ€ ๊ฐ€๋“ ์ฐจ ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ํŒ๋ณ„ํ•œ๋‹ค.
- ํŒŒ์ด์ฌ ๋ฑ ๊ตฌํ˜„์ฒด๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. ๋‹น์—ฐํžˆ ์ด๋ ‡๊ฒŒ ํ‘ธ๋Š”๊ฑด ์•„๋‹ˆ๊ฒ ์ง€ -ใ…‚-... ๋ฌธ์ œ ์กฐ๊ฑด์— ์“ฐ์ง€๋ง๋ผ๊ณ  ๋˜์–ด์žˆ์—ˆ๋‹ค.
- ์ฑ…์„ ๋ณด๋‹ˆ๊นŒ ListNode๋ฅผ ์“ฐ๋Š”๋ฐ, ์ •์˜๊ฐ€ ๋”ฑํžˆ ์—†์–ด์„œ ์—†๋Š”์ค„ ์•Œ์•˜๋Š”๋ฐ, Python์œผ๋กœ ํ•ด๋ณด๋‹ˆ๊นŒ ๋œ๋‹ค.. ๋ญ์ง€..
- ํŒŒ์ด์ฌ์€ ์ข‹๊ธดํ•œ๋ฐ ๊ฐ€๋”์€ ์งœ์ฆ์ด ๋‚œ๋‹ค... ,๋ฅผ .์œผ๋กœ ์ผ๋Š”๋ฐ ์˜ค๋ฅ˜๊ฐ€ ์•ˆ๋‚˜์„œ ๋ญ๊ฐ€๋ฌธ์  ์ง€ ํ•œ์ฐธ ์ฐพ์•˜๋‹ค.
- ๊ทธ๋ฆฌ๊ณ  left, right๋ฅผ ๊ตณ์ด ์„ ์–ธํ•˜์ง€ ์•Š์•„๋„ ์“ธ ์ˆ˜ ์žˆ๋‹ค๋Š”๊ฑธ ์•Œ์•˜๋‹ค. ์‹ ๊ธฐํ•˜๋‹ค..
27. [23. Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/merge_k_sorted_lists/Solution.py)
- k๊ฐœ์˜ ์ •๋ ฌ๋œ ๋ฆฌ์ŠคํŠธ๋ฅผ 1๊ฐœ์˜ ์ •๋ ฌ๋œ ๋ฆฌ์ŠคํŠธ๋กœ ๋ณ‘ํ•ฉํ•˜๋ผ.
- ํŒŒ์ด์ฌ์—์„œ ํž™์„ ์–ด๋–ป๊ฒŒ ์จ์•ผํ• ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค...
- ํ’€์ด๋ฐฉ๋ฒ•๋งŒ ์•Œ๋ฉด ์‰ฌ์šด ๋ฌธ์ œ๋ผ๊ณ  ํ•œ๋‹ค.
- ํŒŒ์ด์ฌ์˜ ํž™์€ ์ตœ์†Œํž™์œผ๋กœ ๊ตฌํ˜„๋˜์–ด์žˆ๋‹ค๊ณ  ํ•œ๋‹ค.
- ์ดํ•ด๋Š” ํ–ˆ์ง€๋งŒ ๋‹ค์‹œ ํ’€์–ด๋ด์•ผ๊ฒ ๋‹ค.
28. [706. Design HashMap](https://leetcode.com/problems/design-hashmap/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/design_hashmap/Solution.py)
- ๋‹ค์Œ์˜ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” ํ•ด์‹œ๋งต์„ ๋””์ž์ธํ•˜๋ผ.
- put(key, value): ํ‚ค, ๊ฐ’์„ ํ•ด์‹œ๋งต์— ์‚ฝ์ž…ํ•œ๋‹ค. ๋งŒ์•ฝ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ํ‚ค๋ผ๋ฉด ์—…๋ฐ์ดํŠธํ•œ๋‹ค.
- get(key): ํ‚ค์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์„ ์กฐํšŒํ•œ๋‹ค. ๋งŒ์•ฝ ํ‚ค๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด -1์„ ๋ฆฌํ„ดํ•œ๋‹ค.
- remove(key): ํ‚ค์— ํ•ด๋‹นํ•˜๋Š” ํ‚ค, ๊ฐ’์„ ํ•ด์‹œ๋งต์—์„œ ์‚ญ์ œํ•œ๋‹ค.
- ๊ทธ๋ƒฅ k๊ฐ€ ๊ณง list์ธ ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ–ˆ๋‹ค. ํฌ๊ธฐ๋Š” ๋™์ผํ•˜๊ฒŒ ์ง€์ •ํ–ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๊ตฌํ˜„ํ•œ ์ด์œ ๋Š” ๊ฐ€์žฅ ๊ณต๊ฐ„์„ ๋งŽ์ด ๋จน์ง€๋งŒ, ๊ฐ€์žฅ ์†๋„๊ฐ€ ๋น ๋ฆ„์„ ์˜ˆ์ƒํ•  ์ˆ˜ ์žˆ์–ด์„œ๋‹ค.
- ํ•ด์‹œ๋ฅผ ํ• ๊ฑฐ๋ผ๋ฉด ์•„๋งˆ ์‚ฌ์ด์ฆˆ๋ฅผ ์ง€์ •ํ•˜๊ณ , %์—ฐ์‚ฐ์ž๋ฅผ ํ™œ์šฉํ•˜์ง€ ์•Š์•˜์„๊นŒ?
- default dict๋ฅผ ์“ฐ๋ฉด ํŒŒ์ด์ฌ ์ค‘์—์„  ๋น ๋ฅธํŽธ์ด๋‹ค.
- ์ฑ…์€ ํ•ด์‹œ๋งต์„ ์ง์ ‘ ๊ตฌํ˜„ํ•œ๋‹ค. ํ•ด์‹ฑ์€ ๊ทธ๋ƒฅ ๋ชจ๋“ˆ๋ผ ์—ฐ์‚ฐ๋งŒ ํ•œ๋‹ค.
29. [771. Jewels and Stones](https://leetcode.com/problems/jewels-and-stones/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/jewels_and_stones/Solution.py)
- J๋Š” ๋ณด์„์ด๋ฉฐ, S๋Š” ๊ฐ–๊ณ  ์žˆ๋Š” ๋Œ์ด๋‹ค. S์—๋Š” ๋ณด์„์ด ๋ช‡ ๊ฐœ๋‚˜ ์žˆ์„๊นŒ? ๋Œ€์†Œ๋ฌธ์ž๋Š” ๊ตฌ๋ถ„ํ•œ๋‹ค.
- ๋จผ์ € ์š”๊ตฌ์‚ฌํ•ญ์„ ๋ณด๋‹ˆ ๋ฌธ์ž ํ•˜๋‚˜ํ•˜๋‚˜๊ฐ€ ์ข…๋ฅ˜์— ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- defaultdict๋ฅผ ํ™œ์šฉํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ฌธ์ œ ์š”๊ตฌ์‚ฌํ•ญ์„ ๋ณด๋‹ˆ J๋Š” ์ค‘๋ณต๋˜์ง€ ์•Š๋Š” ๋ฌธ์ž์—ด์ธ ๊ฒƒ ๊ฐ™๋‹ค.
- ์นด์šดํ„ฐ๋ฅผ ์ด์šฉํ–ˆ๋‹ค. ํ’€์ด๋„ ์นด์šดํ„ฐ๋ฅผ ์“ด๋‹ค. ์†๋„๋Š” 32ms
- ํŒŒ์ด์จ๋‹‰ํ•œ ํ’€์ด๊ฐ€ ์ œ์ผ ๋นจ๋ž๋‹ค. ๋ฆฌ์ŠคํŠธ ์ปดํ”„๋ฆฌํ—จ์…˜์€ ์ฐธ ์‹ ๊ธฐํ•˜๋‹ค.
30. [3. Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/longest_substring_without_repeating_characters/Solution.py)
- ์ค‘๋ณต ๋ฌธ์ž๊ฐ€ ์—†๋Š” ๊ฐ€์žฅ ๊ธด ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ๋ฆฌํ„ดํ•˜๋ผ.
- ์ˆœ์„œ๋Œ€๋กœ ํƒ์ƒ‰ํ•˜๋ฉด์„œ ๊ฐ™์€ ๋ฌธ์ž๊ฐ€ ๋”•์…”๋„ˆ๋ฆฌ์— ์—†์œผ๋ฉด ๊ธธ์ด๋ฅผ ์ฆ๊ฐ€์‹œํ‚ค๊ณ , ์žˆ์œผ๋ฉด ์ดˆ๊ธฐํ™”์‹œ์ผœ์„œ ์ตœ๋Œ€ ๊ธธ์ด๋ฅผ ๊ตฌํ•œ๋‹ค.
- ์ค‘๋ณต๋œ ๋ฌธ์ž๊ฐ€ ๋“ฑ์žฅํ•˜์ง€๋งŒ ๋‹ค๋ฅธ๊ฒŒ ๋” ๊ธด edge case๊ฐ€ ์กด์žฌํ–ˆ๋‹ค. (dvdf)
- ํ’€์ด๋ฅผ ๋ดค๋Š”๋ฐ ๋ญ”๋ง์ธ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค. ์Šฌ๋ผ์ด๋”ฉ ์œˆ๋„์šฐ ๋ฐฐ์šฐ๊ณ  ๋‹ค์‹œ ํ’€์–ด๋ณด์ง€๋ญ...
31. [347. Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/top_k_frequent_elements/Solution.py)
- k๋ฒˆ ์ด์ƒ ๋“ฑ์žฅํ•˜๋Š” ์š”์†Œ๋ฅผ ์ถ”์ถœํ•˜๋ผ.
- ๋ฌธ์ œ ์„ค๋ช…์ด ์ด์ƒํ•œ๋“ฏ.. k ์ˆœ์œ„๊นŒ์ง€ ๋ฝ‘์•„๋‚ด๋Š” ๋“ฏํ•œ ์˜ˆ์ œ ์ผ€์ด์Šค์ž„.
- Counter์˜ most_common์„ ํ™œ์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค.
- zip์ด๋‚˜ asterisk ์–˜๊ธฐ๊ฐ€ ๋‚˜์˜ค๋Š”๋ฐ ๋ด๋„ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ„๋‹ค. ์žฌ๋ฏธ์—†๋‹ค.
32. [200. Number of Islands](https://leetcode.com/problems/number-of-islands/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/number_of_islands/Solution.py)
- 1์„ ์œก์ง€๋กœ, 0์„ ๋ฌผ๋กœ ๊ฐ€์ •ํ•œ 2D ๊ทธ๋ฆฌ๋“œ ๋งต์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ์„ฌ์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋ผ.(์—ฐ๊ฒฐ๋œ 1๋“ค์€ ํ•˜๋‚˜๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.)
- ๋ญ”๊ฐ€ ์–ด๋–ป๊ฒŒ ํ’€๋ฉด ๋ ์ง€๊ฐ€ ๋ช…ํ™•ํ•˜์ง€ ์•Š๋‹ค... DFS, BFS ๋ฌธ์ œ๋ฅผ ์•ˆํ’€์–ด๋ด์„œ ๊ทธ๋Ÿฐ ๊ฒƒ ๊ฐ™๋‹ค ใ… ใ… 
- ๋ฐฉ๋ฌธํ•œ ๊ณณ์„ ์ฒดํฌํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•œ ๊ฒƒ ๊ฐ™๋‹ค. ์ฑ…์˜ ์„ค๋ช…์„ ํ™•์ธํ•ด๊ฐ€๋ฉด์„œ ์ „๋žต์„ ์„ธ์› ๋Š”๋ฐ ๋น„์Šทํ•˜๊ฒŒ ํ‘ผ ๊ฒƒ ๊ฐ™๋‹ค.
- ํŒŒ์ด์ฌ์—๋Š” ํ•จ์ˆ˜ ์•ˆ์— ํ•จ์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ๋Š” ์ค‘์ฒฉ ํ•จ์ˆ˜๋ผ๋Š” ๊ฒƒ์ด ์žˆ๋‹ค. ์Šค์ฝ”ํ”„ ๋•Œ๋ฌธ์— ์ „๋‹ฌํ•ด์คฌ๋˜ ๋ณ€์ˆ˜๋‚˜, self๊ฐ€ ์‚ฌ๋ผ์ ธ์„œ ์ข‹์€ ๊ฒƒ ๊ฐ™๋‹ค.
33. [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/letter_combinations_of_a_phone_number/Solution.py)
- 2์—์„œ 9๊นŒ์ง€ ์ˆซ์ž๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ ์ „ํ™” ๋ฒˆํ˜ธ๋กœ ์กฐํ•ฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅํ•˜๋ผ
- ๋ฌธ์ž ์กฐํ•ฉ์„ ๊ตฌํ•˜๋Š” ๊ฒƒ์ด๋ผ์„œ ๊ทธ ์ˆซ์ž๋กœ ๊ฐ€๋Šฅํ•œ ๋ฌธ์ž์˜ ๊ฒฝ์šฐ๋“ค์„ ์กฐํ•ฉํ•ด์„œ ์ถœ๋ ฅํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ทธ๋ฆฌ๊ณ  ์ˆœ์„œ๊ฐ€ ์ •ํ•ด์ ธ์žˆ์–ด์„œ ์‰ฌ์šด ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ทธ๋ƒฅ ๊ฐ€๋Šฅํ•œ ๋ฌธ์ž๋“ค์„ ์ฃ„๋‹ค ๋ฆฌ์ŠคํŠธ์— ๋„ฃ๊ณ  ํ•ฉ์น˜๋Š” ์‹์œผ๋กœ ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.
- ๋ฆฌ์ŠคํŠธ ์ปดํ”„๋ฆฌํ—จ์…˜ ๋ฐ ํŒŒ์ด์ฌ์˜ ๊ฐ•๋ ฅํ•จ์„ ๋Š๋‚„ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
34. [46. Permutations](https://leetcode.com/problems/permutations/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/permutations/Solution.py)
- ์„œ๋กœ ๋‹ค๋ฅธ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ์ˆœ์—ด์„ ๋ฆฌํ„ดํ•˜๋ผ
- ํŒŒ์ด์ฌ์˜ ๋‚ด์žฅ๋ชจ๋“ˆ์ธ itertools๋ฅผ ํ™œ์šฉํ•˜๋ฉด ๊ฐ„๋‹จํ•˜๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋‹ค.
- ์ฐธ๊ณ : https://medium.com/@dltkddud4403/python-%EC%88%9C%EC%97%B4-%EC%A1%B0%ED%95%A9-%EA%B5%AC%ED%98%84-5e496e74621c
- ์žฌ๊ท€๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค. ๋‹จ, ํŒŒ์ด์ฌ์—์„œ๋Š” itertools๊ฐ€ C์–ธ์–ด๋กœ ๋˜์–ด์žˆ์–ด ์„ฑ๋Šฅ์€ ๋” ์ข‹๋‹ค.
35. [77. Combinations](https://leetcode.com/problems/combinations/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/combinations/Solution.py)
- ์ „์ฒด ์ˆ˜ n์„ ์ž…๋ ฅ๋ฐ›์•„ k๊ฐœ์˜ ์กฐํ•ฉ์„ ๋ฆฌํ„ดํ•˜๋ผ.
- itertools๊ฐ€ ์„ฑ๋Šฅ๋„ ์ข‹๊ณ  ํ’€์ด์†๋„๋„ ๋น ๋ฅด๋‹ค.
- ์žฌ๊ท€๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ดํ•ด๋Š” ํ•ด๋‘์ž.
36. [39. Combination Sum](https://leetcode.com/problems/combination-sum/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/combination_sum/Solution.py)
- ์ˆซ์ž ์ง‘ํ•ฉ candidates๋ฅผ ์กฐํ•ฉํ•˜์—ฌ ํ•ฉ์ด target์ด ๋˜๋Š” ์›์†Œ๋ฅผ ๋‚˜์—ดํ•˜๋ผ. ๊ฐ ์›์†Œ๋Š” ์ค‘๋ณต์œผ๋กœ ๋‚˜์—ด ๊ฐ€๋Šฅํ•˜๋‹ค.
- ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค๋‹ค๋ณด๋‹ˆ ํ†ต๊ณผํ•˜๋Š” ๋กœ์ง์ด ๋˜์—ˆ๋‹ค.
- ์ค‘๋ณต์กฐํ•ฉ์€ start ๊ฐ’์€ ๊ทธ๋Œ€๋กœ ๋„˜๊ฒจ์ฃผ๊ณ , for ๋ฃจํ”„๋ฅผ ๋Œ๋•Œ ๋งˆ๋‹ค ์ฆ๊ฐ€์‹œ์ผœ์ฃผ๋Š” ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค๋ฉด ๋˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.
- start ๊ฐ’์„ ์—†์•ด๋”๋‹ˆ, ์œ„์น˜๋งŒ ๋‹ค๋ฅธ ์ค‘๋ณต๋˜๋Š” ๊ฐ’์ด ๋„์ถœ๋˜์—ˆ๋‹ค.
37. [78. Subsets](https://leetcode.com/problems/subsets/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/subsets/Solution.py)
- ๋ชจ๋“  ๋ถ€๋ถ„ ์ง‘ํ•ฉ์„ ๋ฆฌํ„ดํ•˜๋ผ.
- ์กฐํ•ฉ ์ฝ”๋“œ๋ฅผ ํ™œ์šฉํ•ด๋ณด๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๊ฒฐ๊ณผ์ ์œผ๋กœ ์‹คํŒจ...
- ํ’€์ด๋ฅผ ์ฐธ์กฐํ–ˆ๋‹ค.
38. [332. Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/reconstruct_itinerary/Solution.py)
- [from, to]๋กœ ๊ตฌ์„ฑ๋œ ํ•ญ๊ณต๊ถŒ ๋ชฉ๋ก์„ ์ด์šฉํ•ด JFK์—์„œ ์ถœ๋ฐœํ•˜๋Š” ์—ฌํ–‰ ์ผ์ •์„ ๊ตฌ์„ฑํ•˜๋ผ. ์—ฌ๋Ÿฌ ์ผ์ •์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์‚ฌ์ „ ์–ดํœ˜์ˆœ(Lexical Order)์œผ๋กœ ๋ฐฉ๋ฌธํ•œ๋‹ค.
- ๊ทธ๋ž˜ํ”„๋ฅผ ์–ด๋–ป๊ฒŒ ๊ตฌ์„ฑํ•ด์•ผํ•  ์ง€ ๋ง‰๋ง‰ํ–ˆ๋‹ค.
- ๊ทธ๋ž˜ํ”„ ๊ตฌ์„ฑ ์—†์ด ํ–ˆ๋‹ค๊ฐ€, ๋ฌดํ•œ๋ฃจํ”„์— ๋น ์ ธ๋ฒ„๋ ธ๋‹ค.
- ํ’€์ด๋ฅผ ์ฐธ๊ณ ํ–ˆ๋‹ค. defaultdict๋ฅผ ์‚ฌ์šฉํ•˜๋”๋ผ..
- ์žฌ๊ท€ ํ’€์ด์— ์ต์ˆ™ํ•ด์ง€์ž.
39. [207. Course Schedule](https://leetcode.com/problems/course-schedule/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/course_schedule/Solution.py)
- 0์„ ์™„๋ฃŒํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” 1์„ ๋๋‚ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์„ [0,1] ์Œ์œผ๋กœ ํ‘œํ˜„ํ•˜๋Š” n๊ฐœ์˜ ์ฝ”์Šค๊ฐ€ ์žˆ๋‹ค. ์ฝ”์Šค ๊ฐœ์ˆ˜ n๊ณผ ์ด ์Œ๋“ค์„ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์•˜์„ ๋•Œ ๋ชจ๋“  ์ฝ”์Šค๊ฐ€ ์™„๋ฃŒ ๊ฐ€๋Šฅํ•œ์ง€ ํŒ๋ณ„ํ•˜๋ผ.
- ๊ทธ๋ž˜ํ”„๊ฐ€ ์ˆœํ™˜๊ตฌ์กฐ์ธ์ง€ ํŒŒ์•…ํ•˜๋Š” ๋ฌธ์ œ์ธ๋ฐ, ์ฃผ์–ด์ง„ numCourses๋ฅผ ํ™œ์šฉํ•˜๋ ค๊ณ  ํ•ด๋ดค๋Š”๋ฐ, ์–ด๋””๋‹ค ์“ฐ๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค.
- ์˜ˆ์ œ ์ผ€์ด์Šค๋ฅผ ๋งŒ์กฑํ•˜๋Š” ์ฝ”๋“œ๋„ ์งœ์ง€ ๋ชปํ–ˆ๋‹ค.
- ์ˆœํ™˜๊ตฌ์กฐ๋ฅผ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ์ž‘์„ฑํ–ˆ๋‹ค.
- ๊ฐ€์ง€์น˜๊ธฐ๋ฅผ ์ด์šฉํ•œ ์ตœ์ ํ™”๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.
40. [743. Network Deplay Time](https://leetcode.com/problems/network-delay-time/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/network_delay_time/Solution.py)
- K๋ถ€ํ„ฐ ์ถœ๋ฐœํ•ด ๋ชจ๋“  ๋…ธ๋“œ๊ฐ€ ์‹ ํ˜ธ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์‹œ๊ฐ„์„ ๊ณ„์‚ฐํ•˜๋ผ. ๋ถˆ๊ฐ€๋Šฅํ•  ๊ฒฝ์šฐ -1์„ ๋ฆฌํ„ดํ•œ๋‹ค. ์ž…๋ ฅ๊ฐ’ (u, v, w)๋Š” ๊ฐ๊ฐ ์ถœ๋ฐœ์ง€, ๋„์ฐฉ์ง€, ์†Œ์š” ์‹œ๊ฐ„์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, ์ „์ฒด ๋…ธ๋“œ์˜ ๊ฐœ์ˆ˜๋Š” N์œผ๋กœ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
- ๋‹ค์ต์ŠคํŠธ๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์•Œ๋ฉด ์‰ฝ๊ฒŒ ํ’€๋ฆฌ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
- ๋‹ค์ต์ŠคํŠธ๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•œ ๋ฒˆ ์ง์ ‘ ๊ตฌํ˜„ํ•ด๋ณด๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ง€๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.
41. [787. Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/cheapest_filghts_within_k_stops/Solution.py)
- ์‹œ์ž‘์ ์—์„œ ๋„์ฐฉ์ ๊นŒ์ง€์˜ ๊ฐ€์žฅ ์ €๋ ดํ•œ ๊ฐ€๊ฒฉ์„ ๊ณ„์‚ฐํ•˜๋˜, K๊ฐœ์˜ ๊ฒฝ์œ ์ง€ ์ด๋‚ด์— ๋„์ฐฉํ•˜๋Š” ๊ฐ€๊ฒฉ์„ ๋ฆฌํ„ดํ•˜๋ผ. ๊ฒฝ๋กœ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ -1์„ ๋ฆฌํ„ดํ•œ๋‹ค.
- ๋‹ค์ต์ŠคํŠธ๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‘์šฉํ•ด์•ผ ํ•œ๋‹ค. ์นด์šดํŠธ๋ฅผ ๋ฐ›์•„์„œ ํ•ด์•ผํ•˜๋‚˜?
- dist ๋ฐฐ์—ด์— ๋„ฃ๋Š” ๋ฐฉ์‹์œผ๋กœ ํ–ˆ๋”๋‹ˆ ์ด์ƒํ•˜๊ฒŒ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค. ์•„๋งˆ ๋๊นŒ์ง€ ๋„๋‹ฌํ•˜์ง€ ์•Š์•˜๋‹ค๊ณ  ํŒ์ •ํ•œ ๋“ฏ.. ๊ทธ๋ž˜์„œ ์ฑ…์„ ์ฐธ๊ณ ํ•ด์„œ ๊ทธ๋ƒฅ ๊ฐ™์•„์งˆ ๋•Œ, ๋ฐ˜ํ™˜ํ•˜๋Š” ์‹์œผ๋กœ ์ฒ˜๋ฆฌํ–ˆ๋‹ค.
42. [104. Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/maximum_depth_of_binary_tree/Solution.py)
- ์ฃผ์–ด์ง„ ์ด์ง„ ํŠธ๋ฆ์˜ ์ตœ๋Œ€ ๊นŠ์ด๋ฅผ ๊ตฌํ•˜๋ผ.
- ์žฌ๊ท€์ ์œผ๋กœ ํƒ์ƒ‰ํ•˜๋„๋ก ํ–ˆ๋‹ค. (44ms)
- ํ’€์ด๋Š” BFS๋ฅผ ์‚ฌ์šฉ (52ms) ์™œ ๋” ๋Š๋ฆฌ์ง€...
43. [543. Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/diameter_of_binary_tree/Solution.py)
- ์„œ๋กœ์˜ ๊ฑฐ๋ฆฌ๊ฐ€ ๊ฐ€์žฅ ๋จผ ๋…ธ๋“œ์˜ ๊ฑฐ๋ฆฌ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ผ. ๋ฃจํŠธ๋ฅผ ํ†ตํ• ์ˆ˜๋„ ์žˆ๊ณ  ํ†ตํ•˜์ง€ ์•Š์„์ˆ˜๋„ ์žˆ๋‹ค.
- ๊ฑฐ๋ฆฌ๋Š” ๊ฐ„์„ ์˜ ๊ฐœ์ˆ˜๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋‹ค.
- ์ด์ง„ํŠธ๋ฆฌ์˜ ํŠน์„ฑ์ƒ ๋ฃจํŠธ๋…ธ๋“œ๋ฅผ ์•ˆ๊ฑฐ์น˜๊ณ  ๋‚˜ํƒ€๋‚ด๊ธด ํž˜๋“ค๊ฒƒ ๊ฐ™๋‹ค๊ณ  ์ฒ˜์Œ์— ์ƒ๊ฐํ–ˆ๋‹ค.
- ํ’€์ด๊ฐ€ ๋ญ๊ฐ€ ์ž˜๋ชป๋ฌ๋Š”์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ dfs๋กœ ํ’€์ดํ•˜๋„๋ก ํ–ˆ๋‹ค. ๋‚˜๋Š” ๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด๋ฅผ ์ฐธ๊ณ ํ•ด์„œ `nonlocal`์„ ์‚ฌ์šฉํ–ˆ๋‹ค.
- ์ฑ…์˜ ํ’€์ด๋„ dfs๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ํด๋ž˜์Šค ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.
44. [687. Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/longest_univalue_path/Solution.py)
- ๊ฐ™์€ ๊ฐ’์„ ๊ฐ€์ง„ ๋…ธ๋“œ๊ฐ„์˜ ๊ฑฐ๋ฆฌ์ค‘ ๊ฐ€์žฅ ๊ธด ๊ธธ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ผ.
- ๋ญ๊ฐ€ Easy๋ผ๋Š” ๊ฑด์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค...
- Leet Code์˜ ํ’€์ด๋ฅผ ์ฐธ๊ณ ํ–ˆ๋‹ค.
45. [226. Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/invert_binary_tree/Solution.py)
- ์ขŒ ์šฐ ๋…ธ๋“œ๋ฅผ ๋ฐ˜์ „ํ•˜๋ผ.
- ํŒŒ์ด์ฌ ์‚ฌ๊ธฐ๋‹ค.
46. [617. Merge Two Binary Trees](https://leetcode.com/problems/merge-two-binary-trees/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/merge_two_binary_trees/Solution.py)
- ๋‘ ์ด์ง„ ํŠธ๋ฆฌ๋ฅผ ๋ณ‘ํ•ฉํ•˜๋ผ. ์ค‘๋ณต๋˜๋Š” ๋…ธ๋“œ๋Š” ๊ฐ’์„ ํ•ฉ์‚ฐํ•œ๋‹ค.
- ๊ฐ„๋‹จํ•œ ์žฌ๊ท€ ์กฐ๊ฑด์œผ๋กœ ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
47. [297. Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/)
- ๋‚œ์ด๋„ ์„ธ๊ฐœ๋ผ ์ƒ๋žต
48. [110. Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/balanced_binary_tree/Solution.py)
- ์ด์ง„ ํŠธ๋ฆฌ๊ฐ€ ๋†’์ด ๊ท ํ˜•์ธ ์ด์ง„ํŠธ๋ฆฌ์ธ์ง€ ๋ฐ˜ํ™˜ํ•˜๋ผ.
- ๋†’์ด ๊ท ํ˜•์€ '๋ชจ๋“ ' ๋…ธ๋“œ์˜ ์„œ๋ธŒ ํŠธ๋ฆฌ ๊ฐ„์˜ ๋†’์ด ์ฐจ์ด๊ฐ€ 1 ์ดํ•˜์ธ ๊ฒƒ์„ ๋งํ•œ๋‹ค.
- ํ•จ์ˆ˜๊ฐ€ ํ•ด์•ผํ•˜๋Š” ์—ญํ• ์ด ๋‘ ๊ฐ€์ง€์—ฌ์„œ ์กฐ๊ธˆ ๋งˆ์Œ์— ์•ˆ๋“ค์—ˆ๋‹ค.
- ๊ทผ๋ฐ, ๊ฒฐ๊ตญ์—” ์ด๋ ‡๊ฒŒ ๋งŒ๋“ค์–ด์•ผ ํ•˜๋”๋ผ...
49. [310. Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/minimum_height_trees/Solution.py)
- ๋…ธ๋“œ ๊ฐœ์ˆ˜์™€ ๋ฌด๋ฐฉํ–ฅ ๊ทธ๋ž˜ํ”„๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ํŠธ๋ฆฌ๊ฐ€ ์ตœ์†Œ ๋†’์ด๊ฐ€ ๋˜๋Š” ๋ฃจํŠธ์˜ ๋ชฉ๋ก์„ ๋ฆฌํ„ดํ•˜๋ผ.
- ๊ฐ๊ฐ ์ˆœํšŒํ•˜๋ฉด์„œ ๋†’์ด๋ฅผ ๊ตฌํ•˜๋„๋ก ํ–ˆ๋Š”๋ฐ, ์›ํ•˜๋Š”๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์•˜๋‹ค.
- ํ’€์ด๋ฅผ ๋ณด๋‹ˆ ์žŽ ๋…ธ๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๋ผ๋Š”๋ฐ ์™œ ๊ทธ๋ž˜์•ผํ•˜๋Š”์ง€ ์ดํ•ด๊ฐ€ ์ž˜ ๊ฐ€์ง€ ์•Š์•˜๋‹ค.
50. [108. Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/convert_sorted_array_to_binary_search_tree/Solution.py)
- ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ๋ฐฐ์—ด์„ ๋†’์ด ๊ท ํ˜• ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ๋กœ ๋ณ€ํ™˜ํ•˜๋ผ.
51. [1038. Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/binary_search_tree_to_greater_sum_tree/Solution.py)
- BST์˜ ๊ฐ ๋…ธ๋“œ๋ฅผ ํ˜„์žฌ๊ฐ’๋ณด๋‹ค ๋” ํฐ ๊ฐ’์„ ๊ฐ€์ง„ ๋ชจ๋“  ๋…ธ๋“œ์˜ ํ•ฉ์œผ๋กœ ๋งŒ๋“ค์–ด๋ผ.
- BST์˜ ํŠน์„ฑ์„ ํ™œ์šฉํ•œ ๋ฌธ์ œ
52. [938. Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/range_sum_of_bst/Solution.py)
- ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ(BST)๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ L ์ด์ƒ R ์ดํ•˜์˜ ๊ฐ’์„ ์ง€๋‹Œ ๋…ธ๋“œ์˜ ํ•ฉ์„ ๊ตฌํ•˜๋ผ.
- ๊ฐ„๋‹จํ•˜๊ฒŒ ์žฌ๊ท€๋กœ ๊ตฌํ˜„ํ–ˆ๋‹ค.
- ๋” ํ•œ๋‹ค๋ฉด ๊ฐ€์ง€์น˜๊ธฐ๋ฅผ ํ†ตํ•ด์„œ ๋ฐฐ์ œํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๊ฒ ๋‹ค.
53. [783. Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/minimum_distance_between_bst_nodes/Solution.py)
- ๋‘ ๋…ธ๋“œ ๊ฐ„ ๊ฐ’์˜ ์ฐจ์ด๊ฐ€ ๊ฐ€์žฅ ์ž‘์€ ๋…ธ๋“œ์˜ ๊ฐ’์˜ ์ฐจ์ด๋ฅผ ์ถœ๋ ฅํ•˜๋ผ.
- ๊ฐ’์˜ ์ฐจ์ด๋ฅผ `min` ์„ ์‚ฌ์šฉํ•ด์„œ ๊บผ๋‚ด๋Š” ๋กœ์ง์ด ์ค‘์š”ํ•˜๋‹ค. BST๋ฅผ ์ดํ•ดํ•˜๋ฉด ์–ด๋ ต์ง€ ์•Š๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
54. [105. Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/construct_binary_tree_from_preorder_and_inorder_traversal/Solution.py)
- ํŠธ๋ฆฌ์˜ ์ „์œ„, ์ค‘์œ„ ์ˆœํšŒ ๊ฒฐ๊ณผ๋ฅผ ์ž…๋ ฅ๊ฐ’์œผ๋กœ ๋ฐ›์•„ ์ด์ง„ ํŠธ๋ฆฌ๋ฅผ ๊ตฌ์ถ•ํ•˜๋ผ.
- ์žฌ๋ฐŒ๋Š” ๋ฌธ์ œ์˜€๋‹ค. ์ „์œ„ ์ˆœํšŒ ๊ฒฐ๊ณผ์—์„œ ์ค‘์œ„ ์ˆœํšŒ ๊ฒฐ๊ณผ์™€์˜ ์—ฐ๊ด€์„ฑ์„ ์ด์šฉํ•ด์„œ ํ‘ธ๋Š” ๋ฌธ์ œ์˜€๋‹ค.
- ํ›„์œ„ ์ˆœํšŒ์˜€์œผ๋ฉด ์กฐ๊ธˆ ์ˆœ์„œ๊ฐ€ ๋‹ฌ๋ผ์ง€๊ฒ ์ง€?
55. [215. Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/kth_largest_element_in_an_array/Solution.py)
- heap์„ ์•Œ๋ฉด ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ๋‹ค.
- ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ์ข€ ๋” ๊ฐœ์„ ํ•  ๋ฐฉ๋ฒ•์€ ์—†์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์ž.
56. [208. Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree/)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/leetcode/implement_trie_prefix_tree/Solution.py)
- ํŠธ๋ผ์ด ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ๊ตฌํ˜„ํ•˜๋ผ
- ํ•œ ์‹œ๊ฐ„ ์ •๋„ ๊ฑธ๋ฆฐ ๊ฒƒ ๊ฐ™๋‹ค.(ํŒŒ์ด์ฌ์„ ์ž˜ ๋ชฐ๋ผ์„œ ์ƒ๊ธด ๋ฌธ์ œ...)

### [CodeSignal](https://app.codesignal.com/)

1. [firstNotRepeatingCharacter](https://app.codesignal.com/interview-practice/task/uX5iLwhc6L5ckSyNC)
- ์ฒ˜์Œ์œผ๋กœ ์ค‘๋ณต๋˜์ง€ ์•Š๋Š” ๋ฌธ์ž์—ด ์ฐพ๊ธฐ
- Python์˜ Counter๊ฐ€ ์ด๋Ÿฐ๋ฌธ์ œ์—์„œ ๊ฐ•ํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
- ๋งŒ์•ฝ ์ˆœ์„œ๋ณด์žฅ์ด ์•ˆ๋œ๋‹ค๋ฉด, list์— appendํ•˜๊ณ  ๊ฐ€์žฅ index๊ฐ€ ์ž‘์€ ๊ฐ’์„ ์ง€์ •ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค.

### ์ด๊ฒƒ์ด ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋‹ค

#### ๊ทธ๋ฆฌ๋””

1. ๋ชจํ—˜๊ฐ€ ๊ธธ๋“œ
- ๋ฌธ์ œ์˜ ์กฐ๊ฑด์€ ์ดํ•ดํ–ˆ์ง€๋งŒ, ์‹œ๊ฐ„๋‚ด์— ํ’€์ด์— ์‹คํŒจํ–ˆ๋‹ค. ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ์˜€๋Š”๋ฐ, ์ž˜๋ชป ํ’€์ด๋ฅผ ์„ ํƒํ•ด์„œ ์‹คํŒจํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
2. ๊ณฑํ•˜๊ธฐ ํ˜น์€ ๋”ํ•˜๊ธฐ
- ๋ฌธ์ œ์˜ ์กฐ๊ฑด์„ ์ดํ•ดํ–ˆ๊ณ , ํ’€์ด์™€ ๋™์ผํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค.
3. ๋ฌธ์ž์—ด ๋’ค์ง‘๊ธฐ
- ๋ฌธ์ œ๋ฅผ ์ž˜ ์ดํ•ดํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค. ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด ๊ฒ€์ƒ‰์„ ํ†ตํ•ด์„œ ์ดํ•ดํ–ˆ๋‹ค.

### ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

1. [ํฌ๋ ˆ์ธ ์ธํ˜•๋ฝ‘๊ธฐ ๊ฒŒ์ž„(2019 ์นด์นด์˜ค ๊ฒจ์šธ ์ธํ„ด์‹ญ)](https://programmers.co.kr/learn/courses/30/lessons/64061)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๊ฒจ์šธ%20์ธํ„ด์‹ญ(2019)/ํฌ๋ ˆ์ธ%20์ธํ˜•๋ฝ‘๊ธฐ/solution.py)
- ์ข€ ๋” ์ง‘์ค‘ํ•˜๋ฉด ์ž˜ ํ’€ ์ˆ˜ ์žˆ์—ˆ์„ ๋“ฏ...
- ์†Œ์š”์‹œ๊ฐ„ 1์‹œ๊ฐ„
2. [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ(2020 ์นด์นด์˜ค ์ธํ„ด์‹ญ)](https://programmers.co.kr/learn/courses/30/lessons/67256)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20์ธํ„ด์‹ญ(2020)/ํ‚คํŒจ๋“œ%20๋ˆ„๋ฅด๊ธฐ/solution.py)
- ๋ฌธ์ œ ํ’€์ด ์ž์ฒด๊ฐ€ ์˜ค๋ž˜ ๊ฑธ๋ฆฐ๋“ฏ
- ์†Œ์š”์‹œ๊ฐ„ 30๋ถ„
3. [๋น„๋ฐ€์ง€๋„(2018 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/17681)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2018)/๋น„๋ฐ€์ง€๋„/solution.py)
- ํŒŒ์ด์ฌ ๋ฌธ๋ฒ•์„ ๋ชฐ๋ผ์„œ ์ข€ ๋” ๊ฑธ๋ ธ๋‹ค.
- ์†Œ์š”์‹œ๊ฐ„ 15๋ถ„
4. [์‹คํŒจ์œจ(2019 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/42889)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2019)/์‹คํŒจ์œจ/solution.py)
- try excpet๋ฅผ ์‘์šฉํ–ˆ๋‹ค. lambda ์‹์„ ์ด์šฉํ•œ ์ •๋ ฌ ๊ธฐ์ค€ ์„ค์ •์„ ์‚ฌ์šฉํ–ˆ๋‹ค.
- ํ’€์ด์— ์–ด๋Š์ •๋„ ๋งŒ์กฑํ–ˆ๋‹ค.
- ์†Œ์š”์‹œ๊ฐ„ 21๋ถ„
5. [๋‹คํŠธ ๊ฒŒ์ž„(2018 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/17682)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2018)/๋‹คํŠธ%20๊ฒŒ์ž„/solution.py)
- ํŒŒ์ด์ฌ์œผ๋กœ ์ •๊ทœ์‹ ์ฒ˜๋ฆฌ๊ฐ€ ์•„์ง ๋ฏธ์ˆ™ํ•ด์„œ ์—„์ฒญ ํ•ด๋ฉจ๋‹ค.
- ํ’€์ด๊ฐ€ ์ฉ ๋ง˜์— ๋“ค์ง€ ์•Š์•˜๋‹ค.
- ์†Œ์š”์‹œ๊ฐ„ 35๋ถ„
6. [๋ฌธ์ž์—ด ์••์ถ•(2020 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/60057)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2020)/๋ฌธ์ž์—ด%20์••์ถ•/solution.py)
- ํ•œ ์„ธ๋ฒˆ์งธ ํ‘ธ๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ ํ’€ ๋•Œ๋งˆ๋‹ค ์–ด๋ ค์šด ๋Š๋‚Œ์ด๋‹ค.
- ๊ฒฝ๊ณ„๊ฐ’ ์„ค์ •์„ ์ž˜๋ชปํ•ด์ค˜์„œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ์—ˆ๋‹ค.
- ์†Œ์š”์‹œ๊ฐ„ 35๋ถ„
7. [๊ด„ํ˜ธ ๋ณ€ํ™˜(2020 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/60058)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2020)/๊ด„ํ˜ธ%20๋ณ€ํ™˜/solution.py)
- ํ’€์ด ์‹คํŒจ(30๋ถ„ ์†Œ์š”)
- ๊ท ํ˜•์žกํžŒ ๊ด„ํ˜ธ ๋ฌธ์ž์—ด ์ธ๋ฑ์Šค๋ฅผ ์–ด๋–ป๊ฒŒ ์žก์•„์•ผ ํ• ์ง€ ๊ฐ์ด ์˜ค์ง€ ์•Š์•˜์Œ
- ๋ฌธ์ œ์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๊ตฌํ˜„ํ•˜๋Š”๋ฐ ์–ด๋ ค์›€์ด ์žˆ์—ˆ์Œ
- ์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์€ ์•Œ๊ณ ์žˆ์—ˆ๋Š”๋ฐ, ์–ด๋–ป๊ฒŒ ์ ์šฉํ• ์ง€ ๋ง‰๋ง‰ํ–ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.
8. [ํŠœํ”Œ(2019 ์นด์นด์˜ค ๊ฒจ์šธ ์ธํ„ด์‹ญ)](https://programmers.co.kr/learn/courses/30/lessons/64065)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๊ฒจ์šธ%20์ธํ„ด์‹ญ(2019)/ํŠœํ”Œ/solution.py)
- ํŒŒ์ด์ฌ์ด๋ผ ๋„ˆ๋ฌด ์‰ฌ์šด๋ฌธ์ œ์˜€๋‚˜..?
- ์ •๊ทœ์‹์œผ๋กœ ๊ฑธ๋Ÿฌ๋‚ด๋Š”๊ฒŒ ์ค‘์š”ํ–ˆ๋‹ค.
- ํŠœํ”Œ์˜ ์ˆœ์„œ๋ฅผ ์•Œ์•„๋‚ด๋Š”๊ฒŒ ์‚ด์ง ๊นŒ๋‹ค๋กœ์› ๋‹ค. (๋งŽ์ด ๋‚˜์˜จ ์ˆœ์ด๋ผ๊ณ  ํ•จ)
- ์†Œ์š”์‹œ๊ฐ„ 10๋ถ„
9. [์ˆ˜์‹ ์ตœ๋Œ€ํ™”(2020 ์นด์นด์˜ค ์ธํ„ด์‹ญ)](https://programmers.co.kr/learn/courses/30/lessons/67257)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20์ธํ„ด์‹ญ(2020)/์ˆ˜์‹%20์ตœ๋Œ€ํ™”/solution.py)
- ํ’€์ด ์‹คํŒจ(30๋ถ„ ์†Œ์š”)
- ์ •๊ทœ์‹์œผ๋กœ ์ ‘๊ทผํ–ˆ๋Š”๋ฐ, ๊ตณ์ด ์ •๊ทœ์‹์œผ๋กœ ์ ‘๊ทผํ•˜์ง€ ์•Š์•„๋„ ๋˜์—ˆ์Œ (ํŒŒ์ด์ฌ์˜ `eval()` ํ•จ์ˆ˜๊ฐ€ ์žˆ์–ด์„œ)
- ์šฐ์„ ์ˆœ์œ„ ๋งค๊ธฐ๋Š” ๋ฐฉ์‹์€ ์–ด์ฉ” ์ˆ˜ ์—†์ด ์ผ์ผ์ด ์ ์–ด์ค˜์•ผ ํ•œ๋‹ค.
- ์Šคํƒ์„ ์‚ฌ์šฉํ•˜๋Š” ๋Œ€์‹  ์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ์— ์ฃผ๋ชฉํ–ˆ๋‹ค.
- `join(delimiter)` ํ•จ์ˆ˜๋„ ์œ ์šฉํ•˜๊ฒŒ ์“ธ ์ˆ˜ ์žˆ๋‹ค.
- ํ’€์ด๋ฅผ ๋ณด๋‹ˆ ์šฐ์„ ์ˆœ์œ„์˜ ์ˆœ์„œ๋Š” ํฌ๊ฒŒ ์ค‘์š”ํ•˜์ง€ ์•Š์€ ๊ฐ’์ด์—ˆ๋‹ค. ์ด ๋ถ€๋ถ„๋งŒ ์ข€ ๋” ์‹ ๊ฒฝ์ผ๋‹ค๋ฉด ์ข‹์€ํ’€์ด์˜€์„ ๊ฒƒ ๊ฐ™๋‹ค.
- ํ•œ ํŽธ์œผ๋กœ๋Š” ๋‚ด๊ฐ€ ๋„ˆ๋ฌด ์šฐ์„ ์ˆœ์œ„์— ์ง‘์ฐฉํ•œ ๊ฐ์ด ์—†์ž–์•„ ์žˆ๋‹ค.
10. [๋‰ด์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ง(2018 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/17677)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2018)/๋‰ด์Šค%20ํด๋Ÿฌ์Šคํ„ฐ๋ง/solution.py)
- ์ •๊ทœ์‹๊ณผ Counter(์ค‘๋ณต์ง‘ํ•ฉ)๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฌธ์ œ์˜€๋‹ค.
- ํ•ฉ์ง‘ํ•ฉ์„ ๊ตฌํ•  ๋•Œ, ๊ต์ง‘ํ•ฉ์„ ๋นผ๋Š”๊ฑธ ๊นŒ๋จน์—ˆ๋‹ค.
- ์†Œ์š”์‹œ๊ฐ„ 45๋ถ„
11. [์ž๋ฌผ์‡ ์™€ ์—ด์‡ (2020 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/60059)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2020)/์ž๋ฌผ์‡ ์™€%20์—ด์‡ /solution.py)
- ํ’€์ด ์‹คํŒจ(20๋ถ„ ํ’€์–ด๋ณด๋‹ค ์ ‘๊ทผ์„ ๋ชปํ•˜๊ฒ ์–ด์„œ ํฌ๊ธฐ)
- ๊ตฌํ˜„, ์™„์ „ํƒ์ƒ‰ ๋ฌธ์ œ
- ์ด๋Ÿฐ ๋ฌธ์ œ์— ๋‚ด๊ฐ€ ์•ฝํ•œ ๊ฒƒ ๊ฐ™๋‹ค. ๋ฌธ์ œ ์ ‘๊ทผ์กฐ์ฐจ ํ•˜์ง€ ๋ชปํ–ˆ๋‹ค.
- ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๋Œ€๋žต์ ์œผ๋กœ ๋ถ„์„ํ•ด์„œ ์–ด๋–ป๊ฒŒ ์ ‘๊ทผํ• ์ง€ ์ถ”๋ก ํ•˜๋Š” ๊ฒƒ๋„ ์ค‘์š”ํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
- ๊ตฌํ˜„์˜ ์•„์ด๋””์–ด๋งŒ ์ƒ๊ฐํ•ด๋‚ธ๋‹ค๋ฉด ๋‚ด์šฉ ์ž์ฒด๋Š” ๊ต‰์žฅํžˆ ์‰ฌ์›Œ์ง„๋‹ค.
- ๋‹จ, ์ด์ฐจ์› ๋ฐฐ์—ด ํšŒ์ „์€ ์Šค๋‹ˆํŽซ์— ์ €์žฅํ•ด๋‘๊ณ  ์‚ฌ์šฉํ•ด์•ผ๊ฒ ๋‹ค. (์ด๊ฑด ์–ด๋ ค์›€)
- ์นด์นด์˜ค 1์ฐจ๋Š” ํ†ต๊ณผํ•  ์ˆ˜ ์žˆ์„๊นŒ ใ…Žใ…Ž..
12. [๊ธฐ๋‘ฅ๊ณผ ๋ณด ์„ค์น˜(2020 ์นด์นด์˜ค ๋ธ”๋ผ์ธ๋“œ ์ฑ„์šฉ)](https://programmers.co.kr/learn/courses/30/lessons/60061)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์นด์นด์˜ค%20๋ธ”๋ผ์ธ๋“œ%20์ฑ„์šฉ(2020)/๊ธฐ๋‘ฅ๊ณผ%20๋ณด%20์„ค์น˜/solution.py)
- ํ’€์ด ์‹คํŒจ(1์‹œ๊ฐ„ 10๋ถ„ ํ’€์—ˆ๋Š”๋ฐ, ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋Š” ํ†ต๊ณผํ–ˆ์œผ๋‚˜ ์‹คํŒจ)
- ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋ฌธ์ œ
- ๋ฌธ์ œ์˜ ์กฐ๊ฑด์ด ๋„ˆ๋ฌด ๋ณต์žกํ–ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตฌํ˜„ ๋ณต์žก๋„๊ฐ€ ์ƒ๋‹นํ–ˆ๋‹ค.
- ๊ทธ๋ƒฅ answer์— ๋•Œ๋ ค๋„ฃ๋Š” ๋ฐฉ์‹์œผ๋กœ ํ•ด๊ฒฐํ•˜๋”๋ผ... (์–ด์ฉ์ง€ ๋ฌธ์ œ ์กฐ๊ฑด์— ๋งž๊ฒŒ ํ•˜๋ ค๋ฉด ์ผ๋ฐ˜์ ์ธ ๋ฐฐ์—ด๋กœ๋Š” ์•ˆ๋๋‹ค.)
- ํŒŒ์ด์ฌ ๋“ค์—ฌ์“ฐ๊ธฐ์™€ ์•ฝํƒ€์ž…์˜ ์ฝœ๋ผ๋ณด๋ ˆ์ด์…˜์œผ๋กœ ์˜ค๋ฅ˜๋ฅผ ๋ชป์ฐพ๊ฒ ์—ˆ๋‹ค...
13. [๋‘ ๊ฐœ ๋ฝ‘์•„์„œ ๋”ํ•˜๊ธฐ(์›”๊ฐ„ ์ฝ”๋“œ ์ฑŒ๋ฆฐ์ง€ ์‹œ์ฆŒ1)](https://programmers.co.kr/learn/courses/30/lessons/68644)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/๋‘-๊ฐœ-๋ฝ‘์•„์„œ-๋”ํ•˜๊ธฐ/solution.py)
- 3๋ถ„๋งŒ์— ํ‘ผ ๋ฌธ์ œ(level1์ด๋ผ...)
- 1์ค„๋กœ ํ’€์ดํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
14. [124 ๋‚˜๋ผ์˜ ์ˆซ์ž](https://programmers.co.kr/learn/courses/30/lessons/12899)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/124-๋‚˜๋ผ์˜-์ˆซ์ž/solution.py)
- ํ’€์ด์—์„œ ์ข€ ํ—ค๋งค์„œ 50๋ถ„์ด๋‚˜ ๊ฑธ๋ ธ๋‹ค. 3์ง„๋ฒ•์„ ๋– ์˜ฌ๋ฆฐ ๊ฒƒ ๊นŒ์ง€๋Š” ์ข‹์•˜๋Š”๋ฐ, ๊ทธ ์ดํ›„์— ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•ด์ค˜์•ผ ํ• ์ง€ ๋ชป์ฐพ์•˜๋‹ค.
- ๊ณต๊ฐœ๋œ ํ’€์ด๊ฐ€ ๊น”๋”ํ•ด์„œ ์ฐจ์šฉํ–ˆ๋‹ค.
15. [์ฃผ์‹๊ฐ€๊ฒฉ](https://programmers.co.kr/learn/courses/30/lessons/42584)
- [ํ’€์ด](https://github.com/ksundong/algorithm-solution/blob/master/pysrc/programmers/์ฃผ์‹๊ฐ€๊ฒฉ/solution.py)
- ์ด์ค‘ for๋ฌธ์œผ๋กœ๋„ ํ’€๋ ธ์œผ๋‚˜, ์š”๊ตฌ์‚ฌํ•ญ์ด O(n^2)์„ ์š”๊ตฌํ•˜๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ๊ณ  ํŒ๋‹จํ–ˆ๋‹ค.
- ๋ณต์žก๋„๋ฅผ ๋‚ฎ์ถœ๋งŒํ•œ ๋ฐฉ๋ฒ•์€ stack์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด์—ˆ๋Š”๋ฐ, ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค.
- C++ ์ฝ”๋“œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ์ดํ•ดํ–ˆ๋‹ค.