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
- Python
- error
- ํ๋ก์ ํธ
- ์ฝ๋ฉ์ ํ
- ๋ชจ๊ฐ์ฝ
- ๋๋ฆผ์ฝ๋ฉ
- CSS
- Til
- HTML
- ํฌ๋กค๋ง
- JS
- node.js
- ์ฝ๋ฉ
- ํ์ด์ฌ
- mongodb
- ํ ์ดํ๋ก์ ํธ
- heapq
- ํ๋ก ํธ์๋
- ๋ ธ๋ง๋์ฝ๋
- react
- ๊ตญ๋น์ง์
- javascript
- ์ฝ๋ฉํ ์คํธ
- ๊ทธ๋ฆฌ๋
- ์๊ณ ๋ฆฌ์ฆ
- fe
- ๋ฐฑ์ค
- KDT
- ํ๋ก๊ทธ๋๋จธ์ค
- ๊ฐ๋ฐ
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