LeetCode 561. Array Partition I [Easy]
Problem: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. Example 1: Input: [1,4,3,2] Output: 4 Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + min(3, 4). Note: n is a positive integer, which is in the range of [1, 10000..
2020. 8. 26.
Enumerate
Enumerate 함수는 순서가 있는 자료형 (list, set, tuple..) 을 index를 포함한 값으로 리턴한다. a = [5,4,3,2,1] list(enumerate(a)) ---> [(0,5), (1,4), (2,3), (3,2), (4,1)] 인덱스 값을 가지고 있는 값에 자동으로 순차적 부여.
2020. 8. 12.