본문 바로가기
python-algorithm

leetcode 1464. Maximum Product of Two Elements in an Array

by 무적김두칠 2022. 3. 16.

1
2
3
4
5
6
7
class Solution:
    def maxProduct(self, nums: List[int]) -> int:
        first=max(nums)
        nums.pop(nums.index(first))
        second=max(nums)
        ans=(first-1)*(second-1)
        return ans        
cs
반응형

댓글