250x250
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
- Max
- 데이터전처리
- 내일배움일지
- 가설검정
- DATE_SUB
- Set
- python
- Join
- map
- 리스트
- 반복문
- f-string
- 데이터시각화
- ★
- AB테스트
- 통계학
- 이중for문
- 한줄for문
- 선형회귀
- SQLD
- 시각화
- 태블로
- SQL
- 아티클스터디
- 프로그래머스
- 내배캠_학습기록
- 내일배움캠프
- 다중공선성
- Til
- Leetcode
Archives
- Today
- Total
노력에는 지름길이 없으니까요
프로그래머스 - 예산 (Python ver.) 본문
728x90
해결일 | 언어 | 레벨 | 테스트명 |
20240628 | Python | level 2 | 예산 |
링크 : https://school.programmers.co.kr/learn/courses/30/lessons/12982/solution_groups?language=python3
내 코드
def solution(d, budget):
d.sort()
answer=0
for i in range(len(d)):
budget=budget-d[i]
if budget < 0 : break
answer+=1
return answer
개선점: -
베스트 코드
-
다른 풀이를 좀 살펴봤는데,
sum()을 일일이 구하는 것보다는 budget에서 빼는 쪽이
효율성 (빅오) 면에서 더 낫겠다고 한다.
O(n^2) / O(n) 정도의 차이라고...
알고리즘 시간복잡도 관련해서도 한 번 조사를 해야할 것 같다.
728x90
반응형
'Python > 프로그래머스' 카테고리의 다른 글
프로그래머스 - 삼총사 python ver. (0) | 2024.06.29 |
---|---|
프로그래머스 - 이상한 문자 만들기 Python ver. (0) | 2024.06.28 |
프로그래머스 - 최대공약수와 최소공배수 (0) | 2024.06.28 |
최댓값과 최솟값 (0) | 2024.06.25 |
행렬의 덧셈 - 2차 배열을 한줄 for문으로 표현하는 법 (0) | 2024.06.24 |