알고리즘/배열(array)

Squares of a Sorted Array

자코린이 2023. 6. 26. 22:07

배열의 수를 각각 제곱하고 정렬하는 문제입니다.

class Solution:
    def sortedSquares(self, nums: List[int]) -> List[int]:
        sq_list = []
        for i in nums:
            sq_list.append(i ** 2)
        result = sorted(sq_list)
        return result