일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 스탭퍼
- 영어원서읽기
- 잡생각
- 만화도
- 프로젝트
- 사이드
- leetcode
- Problem Solving
- 뭐든
- 화상영어
- 영어공부
- realclass
- Writing
- 파비최
- 쓰릴오브파이트
- FIT XR
- 개발자
- 링피트
- 30분
- 매일
- Daily Challenge
- 운동
- 10분
- 읽기
- 3줄정리
- 괜찮음
- 리얼 클래스
- 월간
- English
- 미드시청
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.11.19 Today's Challenge 본문
https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal/
Reduction Operations to Make the Array Elements Equal - LeetCode
Can you solve this real interview question? Reduction Operations to Make the Array Elements Equal - Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps: 1. Find the largest value in nu
leetcode.com
생각보다 쉬운 문제
class Solution:
def reductionOperations(self, nums: List[int]) -> int:
nums.sort()
ans, up = 0, 0
for i in range(1, len(nums)):
if nums[i] != nums[i-1]:
up += 1
ans += up
return ans
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.11.21 Today's Challenge (0) | 2023.11.21 |
---|---|
2023.11.20 Today's Challenge (1) | 2023.11.20 |
2023.11.18 Today's Challenge (0) | 2023.11.18 |
2023.11.17 Today's Challenge (0) | 2023.11.17 |
2023.11.16 Today's Challenge (0) | 2023.11.16 |
Comments