Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- ํ ์ดํ๋ก์ ํธ
- ํฌ๋กค๋ง
- error
- ๋ชจ๊ฐ์ฝ
- ์ฝ๋ฉํ ์คํธ
- react
- HTML
- Til
- ์ฝ๋ฉ
- node.js
- mongodb
- CSS
- ๊ฐ๋ฐ
- JS
- heapq
- ์๊ณ ๋ฆฌ์ฆ
- Python
- ๋๋ฆผ์ฝ๋ฉ
- javascript
- ํ๋ก๊ทธ๋๋จธ์ค
- KDT
- ๊ตญ๋น์ง์
- fe
- ๋ ธ๋ง๋์ฝ๋
- ๋ฐฑ์ค
- ์ฝ๋ฉ์ ํ
- ํ์ด์ฌ
- ํ๋ก ํธ์๋
- ํ๋ก์ ํธ
- ๊ทธ๋ฆฌ๋
Archives
- Today
- Total
๋ชฉ๋กํ (1)
๐ฑ → ๐ณ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ ๋งต๊ฒ - python
์ฝ๋ ์๊ฐ์ด๊ณผ ์ฝ๋ from collections import deque def solution(scoville, K): answer = 0 scoville = deque(scoville) while True: scoville = deque(sorted(scoville)) if scoville[0] >= K: break v1 = scoville.popleft() v2 = scoville.popleft() scoville.append(v1+(v2*2)) answer += 1 return answer ์ฌ์ง์ด ๋ช๋ชํ ์คํธ ๋ฐํ์์๋ฌ๋ ๋ฐ์ deque ์ฌ์ฉํด์ ์๋ก์ด ์ค์ฝ๋น์ง์ ๋ค์ด์ฌ ๋ ๋ง๋ค ์ ๋ ฌํด์ค ๋ด๊ฐ ๋ด๋ ๊ตฌ๋ฆฐ ์ฝ๋ .. ์๊ฐ์ด๊ณผ ํด๊ฒฐ ์ฝ๋ from heapq import heapify, heappush,..
Algorithms
2023. 8. 2. 15:35