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.
Leetcode. Squares of a Sorted Array
Problem: Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] -Summary- Squares of each element in Array, then sort them using sort() function. class Solution: def sortedSquares(self, A: List[in..
2020. 7. 4.