-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
24-Hwangyerin #104
24-Hwangyerin #104
Conversation
# μμ(value)λλ‘ μ λ ¬ | ||
final_list = sorted(waiting.items(), key = lambda item: item[1]) | ||
|
||
# μ νμΈμλ³΄λ€ μ μ²μΈμμ΄ μ μ κ²½μ° μ νμΈμμ μ μ²μΈμμΌλ‘ μ΄κΈ°ν | ||
if K > len(final_list): | ||
K = len(final_list) | ||
|
||
# μκ°μ μ²μ μ±κ³΅ν νμμ νλ²μ μΆλ ₯ | ||
for i in range(K): | ||
print(final_list[i][0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리μ€νΈ μ¬λΌμ΄μ±μ μ¬μ©νλ©΄ μ νλ μΈμλ³΄λ€ μ μ² μΈμ κ°μ΄ μ μ κ²½μ°μλ μ μ² μΈμ μ λ§νΌ μΆλ ₯μ΄ κ°λ₯ν©λλ€. λ°λΌμ KκΉμ§μ λ²μλ‘ κ·Έλλ‘ μ¬μ©ν μ μμ΅λλ€ :)
λμ
λ리μ κ²½μ°λ sorted() ν¨μλ₯Ό ν΅ν΄ μ λ ¬μ ν μ μμ΅λλ€.
μλ¬΄λ° μ΅μ
μ μ§μ ν΄μ£Όμ§ μμ κ²½μ° Keyλ₯Ό μ λ ¬ν 리μ€νΈλ₯Ό λ°ννκΈ°λλ¬Έμ key κ°μΈ νλ²μ κ·Έλλ‘ μΆλ ₯ν΄μ€ μ μμ΅λλ€ !
μμ
print(sorted(sugang))
['01234567', '20093778', '20103324', '20103325', '20133221', '20140101']
print(*sorted(sugang, key = lambda x: sugang[x])[:k], sep='\n')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ€μ· κ·Έλ¬λ©΄ λ€μκ³Ό κ°μ΄ μ½λλ₯Ό μμ±ν μ μκ² λ€μ
if K > len(final_list):
print(*sorted(sugang, key = lambda x: sugang[x])[:k], sep='\n')
else:
for i in range(K):
print(final_list[i][0])
μ μλ λλΆμ
μΈν¨νΉκ³Ό νλ¦°νΈ λ¬Έ μ΅μ
sepμ κ°μ΄ μ¬μ©ν μ μλ€λκ±Έ μκ³ κ°λλ€ (λ©λͺ¨..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ μλκ΅°μ, μ μλ μ½λμμλ λμ λ리 μ λ ¬μ‘°μ°¨λ νλ¦°νΈλ¬Έμμ ν΄μ£Όκ³ μκ΅°μ..π€π€π€
μ κ° μ μλ μ½λλ₯Ό λ³΄κ³ λ€μ μμ±ν μ½λκ° μλͺ»λλ€λ κ±Έ μμμ§λ§ κΈ°λ‘μ μν΄ λ¨κ²¨λκ² μ΅λλ€! λλ₯΅.
리μ€νΈ μ¬λΌμ΄μ±μ μ¬μ©νλ©΄ μ νλ μΈμλ³΄λ€ μ μ² μΈμ κ°μ΄ μ μ κ²½μ°μλ μ μ² μΈμ μ λ§νΌ μΆλ ₯μ΄ κ°λ₯. λ©λͺ¨.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ λμ λ리λ₯Ό μ΄μ©ν΄μ μ΄ λ¬Έμ λ₯Ό νμλλ°μ! μ μλμ 리뷰 λλΆμ
Note
리μ€νΈ μ¬λΌμ΄μ±μ΄ μ νλ μΈμλ³΄λ€ μ μ² μΈμ κ°μ΄ μ μ κ²½μ°μλ μ μ² μΈμ μ λ§νΌ μΆλ ₯μ΄ κ°λ₯νλ€
λ κ²μ μκ² λμμ΅λλ€! μ λ λ©λͺ¨ν΄λμΌκ² λ€μπγ γ
λ κ΅ν©λ λλΆμ 리μ€νΈλ₯Ό λ€μ§μ΄μ νν°λ§ ν΄μ£Όλ λ°©λ²λ μλ€λ κ²μ μμκ°λλ€!
dict
ν΄λμ€μ fromkeys()
λ©μλλ νλ μμκ°λ€μπ λ μμΈν μμλ΄μΌκ² μ΅λλ€π
μ΄λ²μ£Όλ λΏμ λ΄ μλΉπ νμ΄ν ππ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ μλ¦°λμ²λΌ 리μ€νΈ μ¬λΌμ΄μ±μ νλλΌλ μκ°μ μ²μΈμμ΄ μ μ² κ°λ₯μΈμλ³΄λ€ μ μ κ²½μ°λ₯Ό λ°λ‘ κ³ λ €ν΄μΌνμ§ μλ μκ°νμλλ° '리μ€νΈ μ¬λΌμ΄μ±μ μ¬μ©νλ©΄ μ νλ μΈμλ³΄λ€ μ μ² μΈμ κ°μ΄ μ μ κ²½μ°μλ μ μ² μΈμ μ λ§νΌ μΆλ ₯μ΄ κ°λ₯ν©λλ€.' λ μ¬μ€μ μμκ°λλ€. μ€λ³΅ ν΄λ¦μ κ²½μ°, 맨 λ§μ§λ§ μ μ²μ κ³ λ €ν΄μΌνλ―λ‘ λ¦¬μ€νΈλ₯Ό λ€μ§μ΄μ£Όλ κ²κ³Ό, setλ‘ νν°λ§ν΄λ μμκ° μ μ§λλ fromkeysλΌλ ν₯λ―Έλ‘μ΄ μμ΄λ μμκ°λλ€!! μ΄λ² pr μ λ§ μκ³ νμ ¨μ΅λλ€ βοΈβ―
π λ¬Έμ λ§ν¬
Baekjoon | μκ°μ μ²
μμ νλ μ΅λ μκ° κ°λ₯ μΈμμ΄ 3λͺ μΈ μκ³ λ¦¬μ¦ μμ μ λν΄ 6λͺ μ νμμ΄ μκ°μ μ²μ μ§νν λͺ¨μ΅μ΄λ€. λ²νΌμ΄ λΉνμ±ν λ ν, λ¨Όμ κ·μΉ 1μ μ μ©νμ¬ ν΄λ¦μ 2λ² μ΄μ ν νμμ μ€λ³΅λ λκΈ°λͺ©λ‘μ μμ νλ€. μ€λ³΅λ λͺ©λ‘μ μ κ±°ν ν, 맨 μμμλΆν° μ΅λ μκ° κ°λ₯ μΈμμΈ 3λͺ μ μ μ νλ€. νμ 맨 μ€λ₯Έμͺ½μλ κ·Έ μ΅μ’ κ²°κ³Όλ₯Ό λνλΈ λͺ¨μ΅μ΄λ€. μ΄μ κ°μ λ°©λ²μ μ΄μ©νμ¬ μ΅μ’ μ μΌλ‘ μκ°μ μ²μ μ±κ³΅ν μΈμμ μΆλ ₯νλ νλ‘κ·Έλ¨μ μμ±νμμ€.
βοΈ μμλ μκ°
30λΆ
β¨ μλ μ½λ
β³ νμμ νλ²μ ν€(key)λ‘ μμλ νμ¬ ν€κ° μ λ ₯λ μμ(μΈλ±μ€)λ‘, μ¦ λ λ² μ΄μ ν΄λ¦ν νμμ μμ°μ€λ½κ² μΈλ±μ€κ° λ€λ‘ λμ΄κ°
μ΄ λ μκ°νμ§ λͺ» ν κ²½μ°κ° νκ°μ§ μμλ€.
μκ°μ μ²ν νμ μκ° μ νμΈμλ³΄λ€ λ λ§μ λλ λ¬Έμ κ° λμ§ μλλ€.
λ°λλ‘, μκ°μ μ²ν νμ μκ° μ μμ μ±μ°μ§ λͺ»νμ κ²½μ°λ₯Ό κ³ λ €νμ§ λͺ»νλ€.
κ·Έ λΆλΆμ κ°λ¨νκ² μΆλ ₯ μΈμμ Kμμ λκΈ°μ΄μ μλ νμ μλ‘ λ³κ²½ν΄μ£Όλ©΄ λλ€.
βοΈ μ΅μ’ μ½λ
π μλ‘κ² μκ²λ λ΄μ©