Skip to content

๐Ÿ€ ๋งค์ผ๋งค์ผ ํ‘ธ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ !

Notifications You must be signed in to change notification settings

wwlee94/everyday-algorithm

Repository files navigation

๐Ÿ’ป everyday-algorithm

๋งค์ผ Python, Java๋กœ ํ‘ธ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ !

๐Ÿ’๐Ÿปโ€โ™‚๏ธ ๋‚˜๋งŒ์˜ Rule ์ •ํ•˜๊ธฐ !

  • ํ•˜๋ฃจ์— ์ตœ์†Œ 1๊ฐœ์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ’€๊ธฐ
  • ๋ชป ํ‘ธ๋Š” ๋ฌธ์ œ๋ผ๋„ ์ตœ๋Œ€ํ•œ ๊ณ ๋ฏผํ•ด๋ณด๊ธฐ
  • ๋ˆ„๊ตฌ๋‚˜ ๋ณด์•„๋„ ์ดํ•ด ํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ์™€ ํ’€์ด๋ฅผ ์ž‘์„ฑํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ•˜๊ธฐ

์Šคํ„ฐ๋”” ์ •๋ฆฌ

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป ๋ฌธ์ œ ํ’€์ด ๋ฐ ์ฝ”๋“œ

Python

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

  1. ์Šคํƒ / ํ
  2. ํ•ด์‰ฌ
  3. ํž™
  4. ์™„์ „ ํƒ์ƒ‰
  5. ์ •๋ ฌ
  6. ๊ทธ๋ฆฌ๋””
  7. DFS/BFS
  8. ๊ทธ๋ž˜ํ”„
  9. ์ด์ง„ ํƒ์ƒ‰
  10. DP

๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜

  1. ๊ทธ๋ฆฌ๋””
  2. ํƒ์ƒ‰
  3. DFS/BFS
  4. ํ”Œ๋กœ์ด๋“œ ์™€์ƒฌ
  5. DP

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์—ฐ์Šต๋ฌธ์ œ

  1. LEVEL 1

  2. LEVEL 2

  3. LEVEL 3

2020 ์นด์นด์˜ค ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ

2019 ์นด์นด์˜ค ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ

2018 ์นด์นด์˜ค ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ

2019 ๋ผ์ธ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ

2018 ์œˆํ„ฐ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ

Java

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

  1. ์Šคํƒ / ํ
  2. ํ•ด์‰ฌ
  3. ํž™
  4. ์™„์ „ ํƒ์ƒ‰
  5. ์ •๋ ฌ
  6. DFS/BFS
  7. ๊ทธ๋ž˜ํ”„

JavaScript

๋‹ค์–‘ํ•œ ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ๋ฒ• ์ •๋ฆฌ

์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‚ฌ์ดํŠธ

์ž๋ฃŒํ˜• ๋ณ„ ์ฃผ์š” ์—ฐ์‚ฐ์ž ์‹œ๊ฐ„ ๋ณต์žก๋„

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ํ’€๋‹ค ๋ณด๋ฉด ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ์ƒ๊ฐํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ข…์ข… ์ƒ๊ธด๋‹ค.
์‹œ๊ฐ„๋ณต์žก๋„ ๊ธฐ์ค€์ด ์žˆ์–ด์„œ, ๊ธฐ์ค€์„ ๋„˜๊ธฐ์ง€ ๋ชปํ•˜๋ฉด ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋„ ํ‹€๋ฆฌ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ธด๋‹ค.

Python

list

Operation Example Big-O Notes
Index l[i] O(1) ย 
Store l[i] = 0 O(1) ย 
Length len(l) O(1) ย 
Append l.append(5) O(1) ย 
Pop l.pop() O(1) l.pop(-1) ๊ณผ ๋™์ผ
Clear l.clear() O(1) l = [] ๊ณผ ์œ ์‚ฌ
Slice l[a:b] O(b-a) l[:] : O(len(l)-0) = O(N)
Extend l.extend(โ€ฆ) O(len(โ€ฆ)) ํ™•์žฅ ๊ธธ์ด์— ๋”ฐ๋ผ
Construction list(โ€ฆ) O(len(โ€ฆ)) ์š”์†Œ ๊ธธ์ด์— ๋”ฐ๋ผ
check ==, != l1 == l2 O(N) ๋น„๊ต
Insert ใ…ฃ.insert(i, v) O(N) i ์œ„์น˜์— v๋ฅผ ์ถ”๊ฐ€
Delete del l[i] O(N) ย 
Remove l.remove(โ€ฆ) O(N) ย 
Containment x in/not in l O(N) ๊ฒ€์ƒ‰
Copy l.copy() O(N) l[:] ๊ณผ ๋™์ผ - O(N)
Pop l.pop(i) O(N) l.pop(0):O(N)
Extreme value min(l)/max(l) O(N) ๊ฒ€์ƒ‰
Reverse l.reverse() O(N) ๊ทธ๋Œ€๋กœ ๋ฐ˜๋Œ€๋กœ
Iteration for v in l: O(N) ย 
Sort l.sort() O(N Log N) ย 
Multiply k*l O(k N) [1,2,3] * 3ย ยป O(N**2)

Dict

Operation Example Big-O Notes
Index d[k] O(1) ย 
Store d[k] = v O(1) ย 
Length len(d) O(1) ย 
Delete del d[k] O(1) ย 
get/setdefault d.method O(1) ย 
Pop d.pop(k) O(1) ย 
Pop item d.popitem() O(1) ย 
Clear d.clear() O(1) s = {} or = dict() ์œ ์‚ฌ
View d.keys() O(1) d.values() ๋™์ผ
Construction dict(โ€ฆ) O(len(โ€ฆ)) ย 
Iteration for k in d: O(N) ย 

References (์ฐธ๊ณ  ์‚ฌ์ดํŠธ)

Java

LIST

Class Name Add Remove Get Contains Iterator.remove
ArrayList O(1) O(n) O(1) O(n) O(n)
LinkedList O(1) O(1) O(n) O(n) O(1)

SET

Class Name Add Contains Next
HashSet O(1) O(1) O(h/n) - h๋Š” ํ…Œ์ด๋ธ” ์šฉ๋Ÿ‰
LinkedHashSet O(1) O(1) O(1)
EnumSet O(1) O(1) O(1)
TreeSet O(log n) O(log n) O(log n)

Queue

Class Name Offer Peak Poll Size
PriorityQueue O(log n) O(1) O(log n) O(1)
LinkedList O(1) O(1) O(1) O(1)
ArrayDequeue O(1) O(1) O(1) O(1)
DelayQueue O(log n) O(1) O(log n) O(1)

Map

Class Name Get ContainsKey Next
HashMap O(1) O(1) O(h/n) - h๋Š” ํ…Œ์ด๋ธ” ์šฉ๋Ÿ‰
LinkedHashMap O(1) O(1) O(1)
EnumMap O(1) O(1) O(1)
TreeMap O(log n) O(log n) O(log n)

References (์ฐธ๊ณ  ์‚ฌ์ดํŠธ)

About

๐Ÿ€ ๋งค์ผ๋งค์ผ ํ‘ธ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ !

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published