Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- leetcode
- SW Expert Academy
- 데이콘
- github
- Git
- 코로나19
- 우분투
- ubuntu
- 편스토랑 우승상품
- 파이썬
- 편스토랑
- ChatGPT
- Real or Not? NLP with Disaster Tweets
- 프로그래머스 파이썬
- 캐치카페
- AI 경진대회
- hackerrank
- dacon
- gs25
- Docker
- Kaggle
- 백준
- 프로그래머스
- PYTHON
- programmers
- Baekjoon
- 자연어처리
- 금융문자분석경진대회
- 맥북
- 더현대서울 맛집
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 977. Squares of a Sorted Array (Python) 본문
728x90
반응형
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]
Note:
- 1 <= A.length <= 10000
- -10000 <= A[i] <= 10000
- A is sorted in non-decreasing order.
Solution
class Solution:
def sortedSquares(self, A: List[int]) -> List[int]:
sqrt_list = [pow(num, 2) for num in A]
answer = sorted(sqrt_list)
return answer
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 1480. Running Sum of 1d Array (Python) (0) | 2020.09.02 |
---|---|
[leetCode] 728. Self Dividing Numbers (Python) (0) | 2020.09.01 |
[leetCode] 1281. Subtract the Product and Sum of Digits of an Integer (Python) (0) | 2020.08.30 |
[leetCode] 1556. Thousand Separator (Python) (0) | 2020.08.29 |
[leetCode] 709. To Lower Case (Python) (0) | 2020.08.15 |
Comments