-
Notifications
You must be signed in to change notification settings - Fork 2
문제 016 : 기능 개발 #65
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
base: solutions
Are you sure you want to change the base?
문제 016 : 기능 개발 #65
Conversation
👋 @tiaz0128 님 안녕하세요! 07장 큐
|
🎉 @tiaz0128 님. 축하 합니다! 문제 도움이 필요한 사람들이 있으면 도와주세요! 소통하면서 더 성장 할 수 있는 좋은 기회입니다! |
✨ 아래의 코드는 테스트를 통과한 코드입니다. from collections import deque
def solution(progresses, speeds):
pq = deque(zip(progresses, speeds))
stack = []
while pq:
for idx, (pro, speed) in enumerate(pq):
pq[idx] = (pro + speed, speed)
cnt = 0
for item in pq:
if item[0] >= 100:
cnt += 1
else:
break
if cnt > 0:
for _ in range(cnt):
pq.popleft()
stack.append(cnt)
return stack |
🎉 @tiaz0128 님. 축하 합니다! 문제 도움이 필요한 사람들이 있으면 도와주세요! 소통하면서 더 성장 할 수 있는 좋은 기회입니다! |
✨ 아래의 코드는 테스트를 통과한 코드입니다. import math
def solution(progresses, speeds):
answer = []
n = len(progresses)
days_left = [math.ceil((100 - progresses[i]) / speeds[i]) for i in range(n)]
max_left = days_left[0]
cnt = 0
stack = []
for day in days_left:
if day <= max_left:
cnt += 1
else:
stack.append(cnt)
cnt = 1
max_left = day
stack.append(cnt)
return stack |
큐를 안쓰고 푸는 방법은 다행이 효율성을 묻지 않는 문제였기 때문에 최대한 효율이 높은 코드를 작성하는게 좋을듯 하다. |
소요시간
사용한 자료구조, 알고리즘
해당 자료구조, 알고리즘을 사용한 근거
어려웠던 구현 포인트
구현한 코드의 시간 복잡도
추가한 테스트 케이스와 그 이유
개선이 필요한 부분은?