1
2
3
4
5
6
7
8
9
|
class Solution:
def minimumOperations(self, nums: List[int]) -> int:
answer = 0
for num in nums:
if num % 3 != 0:
answer += 1
return answer
|
cs |
case 1 ) 숫자가 3으로 나눴을때 나머지 가 0 인 경우 : 아무것도 안해도됨
case 2 ) 숫자가 3으로 나눴을때 나머지 가 1 인 경우 : 1을 빼면됨
case 3 ) 숫자가 3으로 나눴을때 나머지 가 2 인 경우 : 1을 더하면됨
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3280. Convert Date to Binary (1) | 2024.09.12 |
---|---|
leetcode 1684. Count the Number of Consistent Strings (0) | 2024.09.12 |
leetcode 3270. Find the Key of the Numbers (0) | 2024.09.02 |
백준 31994 강당 대관 (0) | 2024.07.15 |
백준 32025 체육은 수학과목 입니다 (0) | 2024.07.15 |
댓글