일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 화상영어
- 링피트
- English
- 파비최
- realclass
- 괜찮음
- 뭐든
- 영어공부
- Daily Challenge
- 스탭퍼
- Writing
- 매일
- 만화도
- 잡생각
- Problem Solving
- leetcode
- 개발자
- 10분
- 사이드
- 월간
- 30분
- 프로젝트
- 운동
- 영어원서읽기
- 리얼 클래스
- 3줄정리
- FIT XR
- 읽기
- 미드시청
- 쓰릴오브파이트
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.03.29 Today's Challenge 본문
https://leetcode.com/problems/reducing-dishes/
Reducing Dishes - LeetCode
Can you solve this real interview question? Reducing Dishes - A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is defined as the time taken to cook that dish incl
leetcode.com
선 정렬후 풀면 되는 문제. 생각보다 간단
class Solution:
def maxSatisfaction(self, satisfaction: List[int]) -> int:
satisfaction.sort(reverse=True)
n = len(satisfaction)
presum, res = 0, 0
for i in range(n):
presum += satisfaction[i]
if presum < 0:
break
res += presum
return res
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.03.31 Today's Challenge (0) | 2023.03.31 |
---|---|
2023.03.30 Today's Challenge (0) | 2023.03.30 |
2023.03.28 Today's Challenge (0) | 2023.03.28 |
2023.03.27 Today's Challenge (0) | 2023.03.27 |
2023.03.26 Today's Challenge (0) | 2023.03.26 |
Comments