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