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 | 31 |
Tags
- 넥슨개발자컨퍼런스
- static #자바 메모리 구조 #멤버 변수
- software enginner
- server engineer
- 반복문
- tibero 7.23
- 2026 하반기 대기업 반드시 갑니다
- 주니어 백엔드 개발자
- server developer
- 서버 개발자
- java #예외처리 #throw #throws
- Next.js
- 2798블랙잭
- 이분탐색
- 정보처리기사 실기 #정처기 실기 #2024년 2회 #정처기 2024년 2회 #공부법 # 꿀팁
- Spring
- level3
- 올 겨울은 조금 따뜻할 것 같다.
- 서버 엔지니어
- 25304번
- level2
- 브루트 포스법
- 백엔드 개발자 로드맵
- tmax tibero
- java #추상클래스
- 나는야 4학년 #5학년 까지 가보자구
- ndc2025
- heap area #stack area #static area #jvm
- object 클래스 # java
- 자바 #자바문법 #자바기초 #참조형 #기본형
Archives
- Today
- Total
개발자 쿠키
[프로그래머스/python] Lv.2 기능개발 본문
기능개발
https://school.programmers.co.kr/learn/courses/30/lessons/42586
def solution(progresses, speeds):
answer = []
for i in range(len(progresses)):
days = (100 - progresses[i] + speeds[i] - 1) // speeds[i]
answer.append(days)
stack = []
score = answer[0]
count = 1
for i in range(1, len(answer)):
if score >= answer[i]:
count += 1
else:
stack.append(count)
score = answer[i]
count = 1
stack.append(count)
return stack
풀이
days 변수에 100에서 progresses[i]를 빼주고 + speeds[i]를 더해준뒤 1을 뺀다 그리고
그 값에서 speeds를 나누어주면 100이상이 될 때 몇번 걸리는지 값이 나온다.
score라는 변수에 첫번째 값을 저장해주고 score가 answer[i] 보다 크거나 같다면 score가 개발될 동안
answer[i]수도 개발이 되므로 count += 1을 해준다.
만약 answer[i]가 stack에 count를 추가해주고 score를 answer[i]로 기준점을 바꿔준다. 그리고
count를 1로 바꾼다.
'algorithm' 카테고리의 다른 글
| [백준] BFS와 DFS 백준 파이썬, 추천 문제, 누구나 쉽게 DFS BFS 이해시키기 (0) | 2024.08.17 |
|---|---|
| [프로그래머스/python] Lv.2 프로세스 (0) | 2024.08.07 |
| [백준(BOJ)]15650번 : 15650 N과 M (2) - Python(파이썬) - (실버3, 순열과 조합) (2) | 2024.08.01 |
| [프로그래머스/python] Lv.2 2019 카카오 개발자 겨울 인턴십 튜플 (0) | 2024.07.08 |
| [프로그래머스/python] Lv.2 할인 행사 (0) | 2024.07.06 |