본문 바로가기

IT/코딩테스트

[Leetcode] 977. Squares of a Sorted Array

728x90

https://leetcode.com/problems/squares-of-a-sorted-array/

class Solution:
    def sortedSquares(self, nums: List[int]) -> List[int]:
        nums = sorted(nums, key=abs)
        return [i * i for i in nums]

 

728x90