[리트코드/파이썬] 561. Array Partition(그리디)
[리트코드/파이썬] 561. Array Partition(그리디) 561. Array Partition 난이도: Easy Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. Example 1: Input: nums = [1,4,3,2] Output: 4 Explanation: All possible pairings (ignoring the ordering of elements) are: 1. (1, 4), (2,..
2023. 12. 11.
[리트코드/파이썬] 15. 3Sum(투 포인터)
[리트코드/파이썬] 15. 3Sum(투 포인터) 난이도: Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example 1: Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0. nums[1] + n..
2023. 12. 11.