
π To Do List
βοΈ μ½ν μκ³ λ¦¬μ¦ κ°μ - LinkedList λ¬Έμ , μ΄μ§νμ
βοΈ μ΄λ ₯μ μ΄μ μμ±
βοΈ μ¬μ΄λ νλ‘μ νΈ - refresh token λ°κΈ λ‘μ§ μμ
π©π»π» Today I Learned ...
Linked List
μ«μ λ³ν ν¨ν΄
μ΄κΈ°κ°: sum = 0
1. 0 * 10 + 6 = 6 (6)
2. 6 * 10 + 7 = 67 (μμ μλ¦¬λ‘ λ°κ³ 7 μΆκ°)
3. 67 * 10 + 8 = 678 (λ°±μ μλ¦¬λ‘ λ°κ³ 8 μΆκ°)
`[6] -> [7] -> [8]` μ΄λ κ² μ΄μ΄μ§ λ§ν¬λ 리μ€νΈλ₯Ό `678` μ«μ ννλ‘ λ³νν λ
κΈ°μ‘΄ μ«μλ₯Ό 10λ°°λ‘ κ³±νκ³ , νμ¬ μ«μλ₯Ό λν΄μ μΌμͺ½μΌλ‘ μλ¦Ώμλ₯Ό νμ₯ν μ μλ€.
μ½λλ‘ νννλ©΄ μλμ κ°λ€.
sum = sum * 10 + cur.data
# 0 → 6 → 67 → 678
μ΄μ§ νμ(Binary Search)
# μ΅μ νμ νκ² μ΅λ
# [0, 3, 5, 6, 1, 2, 4]
# UP -> [1, 2, 4]
# DOWN -> [0, 3, 5]
def is_exist_target_number_binary(target, array):
current_min = 0
current_max = len(array) - 1
current_guess = (current_min + current_max) // 2 # βοΈ κ°μ΄λ° κΈ°μ€μ
while current_min <= current_max:
if array[current_guess] == finding_target:
return True
elif array[current_guess] < target:
# UP
current_min = current_guess + 1
else: # array[current_guess] > target
# DOWN
current_max = current_guess - 1
current_guess = (current_min + current_max) // 2
return False
- λ§€λ² νμ λ²μλ₯Ό μ λ°μΌλ‘ μ€μΈλ€.
- κ°μ΄λ° κ°λΆν° νμΈνμ¬, μ μ νμ λ²μλ₯Ό μ€μΈλ€. (μ€λ₯Έμͺ½ or μΌμͺ½)
- μ λ€μ΄ κ²μμ μλ‘ κΈ°μ΅νλ©΄ μ½λ€.
- μΌλ° νμ
- 1κ°μ© νμΈ→ μ΅λ Nλ²
- μκ° λ³΅μ‘λ : `O(N)`
- μ΄μ§ νμ
- μ λ ₯ λ²μκ° λ§€λ² κ°μ
- μκ° λ³΅μ‘λ : `O(log N)`
π‘ pythonμμ μ«μ λ΄λ¦Ό
- `//` μ°μ°μλ₯Ό μ΄μ©νλ©΄ μμμ μ΄νμ μλ₯Ό λͺ¨λ λ²λ¦¬κ³ λͺ«λ§ λνλΌ μ μλ€.
>>> print((4 + 5) / 2)
4.5
>>> print((4 + 5) // 2)
4
μ΄μ§ νμ μ μ 쑰건
- μ λ ¬λ λ°°μ΄μμλ§ μ¬μ© κ°λ₯νλ€.
- μ λ ¬λμ§ μμ λ°°μ΄μΈ κ²½μ°, κ°μ΄λ° κ° κΈ°μ€μΌλ‘ μ΄λ€ λΆλΆμ νμν΄μΌ νλμ§ μ μ μλ€.
π μ΄μ§ νμ μ½ν λ¬Έμ μ ν
1. μ΅λ/μ΅μ κ° κ΅¬νκΈ°
2. μ λ΅ ν보λ₯Ό λ£κ³ "κ°λ₯" μ¬λΆ νλ¨ ex)κΈΈμ΄κ° 10μ΄λ©΄ κ°λ₯?
3. λ²μκ° μμ² νΌ
4. μ λ ¬λ μν or μ λ ¬ κ°λ₯ν λ°μ΄ν°
5. μμ νμ ν κ²½μ° μκ° μ΄κ³Όλ κ² κ°μ λ
'Today I Learned π§' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
| [TIL-20260205] Access Token μ¬λ°κΈ ꡬν (0) | 2026.02.05 |
|---|---|
| [TIL-20260204] μ½λ© ν μ€νΈ - μ¬κ· ν¨μ (Recursive Function) (0) | 2026.02.04 |
| [TIL-20260202] Kotlin data class, enum class (0) | 2026.02.02 |
| [TIL-20260131] Docker μ΄λ―Έμ§ λ€λ£¨κΈ° (0) | 2026.01.31 |
| [TIL-20260129] Docker 컨ν μ΄λ λ€λ£¨κΈ° (0) | 2026.01.30 |