| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 프로젝트
- 만화도
- 개발자
- 리얼 클래스
- 미드시청
- 사이드
- 괜찮음
- 잡생각
- 운동
- 쓰릴오브파이트
- 스탭퍼
- 읽기
- 뭐든
- 매일
- realclass
- 화상영어
- Problem Solving
- 30분
- FIT XR
- 파비최
- 링피트
- 영어원서읽기
- 월간
- 3줄정리
- leetcode
- Writing
- English
- 영어공부
- 10분
- Daily Challenge
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.04.05 Today's Challenge 본문
https://leetcode.com/problems/minimize-maximum-of-array/
Minimize Maximum of Array - LeetCode
Can you solve this real interview question? Minimize Maximum of Array - You are given a 0-indexed array nums comprising of n non-negative integers. In one operation, you must: * Choose an integer i such that 1 <= i < n and nums[i] > 0. * Decrease nums[i] b
leetcode.com
탐욕법의 다른 활용 예
class Solution:
def minimizeArrayValue(self, nums: List[int]) -> int:
answer, ps = 0, 0
for i in range(len(nums)):
ps += nums[i]
answer = max(answer, math.ceil(ps / (i+1)))
return answer반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| 2023.04.07 Today's Challenge (0) | 2023.04.07 |
|---|---|
| 2023.04.06 Today's Challenge (0) | 2023.04.06 |
| 2023.04.04 Today's Challenge (0) | 2023.04.04 |
| 2023.04.03 Today's Challenge (0) | 2023.04.03 |
| 2023.04.02 Today's Challenge (0) | 2023.04.02 |
Comments