Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 릿코드 풀기
- 릿코드풀이
- 릿코드
- python zip_longest
- 파이썬 알고리즘
- 파이썬알고리즘
- python sorted
- python Leetcode
- leetcode풀이
- 릿코드 파이썬
- python xor
- 상가수익률계산기
- 코틀린기초
- python 알고리즘
- 파이썬 릿코드
- leetcode 풀기
- LeetCode
- 잇츠디모
- 알고리즘풀기
- python 릿코드
- 파이썬알고리즘풀기
- binary search
- 파이썬 알고리즘 풀기
- python priority queue
- 릿코드풀기
- 파이썬릿코드
- leetcode풀기
- 알고리즘풀이
- 파이썬릿코드풀기
- 파이썬 프로그래머스
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀기 - 1877. Minimize Maximum Pair Sum in Array 본문
반응형
1877. Minimize Maximum Pair Sum in Array
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/
Minimize Maximum Pair Sum in Array - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제)

솔루션1)
오름차순 정렬 후 최소, 최대 pair를 계속 구해나가서 max를 구한다.

class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
pairs = []
for i in range(int(len(nums)/2)):
pairs.append(nums[i] + nums[len(nums) - 1 - i])
return max(pairs)
솔루션2)
class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
res = 0
for i in range(len(nums)//2):
res = max(res, nums[i] + nums[len(nums) - 1 - i])
return res
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
LeetCode 풀기 - 1688. Count of Matches in Tournament (0) | 2021.11.08 |
---|---|
LeetCode 풀기 - 1342. Number of Steps to Reduce a Number to Zero (0) | 2021.11.07 |
LeetCode 풀기 - 1281. Subtract the Product and Sum of Digits of an Integer (0) | 2021.11.06 |
LeetCode 풀기 - 1720. Decode XORed Array (0) | 2021.11.06 |
LeetCode 풀기 - 1221. Split a String in Balanced Strings (0) | 2021.11.06 |