728x90
리스트 nums의 요소들을 제곱 후 정렬하는 문제
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
return sorted([x**2 for x in nums])
nums 내부의 x를 제곱하여 sorted한 것을 return
Runtime : 4ms (89.92%)
Memory : 19.3MB (15.60%)
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 160. Intersection of Two Linked Lists (0) | 2025.02.09 |
---|---|
[Python] 142. Linked List Cycle II (0) | 2025.02.08 |
[Python] 1726. Tuple with Same Product (0) | 2025.02.06 |
[Python] 3151. Special Array I (0) | 2025.02.06 |
[Python] 141. Linked List Cycle (0) | 2025.02.05 |