일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- FIT XR
- 영어공부
- 스탭퍼
- 사이드
- 월간
- 리얼 클래스
- 30분
- Daily Challenge
- 쓰릴오브파이트
- 화상영어
- 운동
- 개발자
- 잡생각
- 미드시청
- Writing
- 영어원서읽기
- leetcode
- 파비최
- 10분
- 3줄정리
- English
- 프로젝트
- 읽기
- Problem Solving
- 괜찮음
- realclass
- 뭐든
- 만화도
- 링피트
- 매일
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.12.13 Today's Challenge 본문
https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/
Maximum Product of Two Elements in an Array - LeetCode
Can you solve this real interview question? Maximum Product of Two Elements in an Array - Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). Example 1: Inpu
leetcode.com
가장 큰 값 2개 뽑아서 계산하면 끝
class Solution:
def maxProduct(self, nums: List[int]) -> int:
nums.sort(reverse=True)
return (nums[0]-1) * (nums[1]-1)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.12.15 Today's Challenge (0) | 2023.12.15 |
---|---|
2023.12.14 Today's Challenge (0) | 2023.12.14 |
2023.12.12 Today's Challenge (0) | 2023.12.12 |
2023.12.11 Today's Challenge (0) | 2023.12.11 |
2023.12.10 Today's Challenge (0) | 2023.12.10 |
Comments