Day2 Two Pointers - LeetCode 14day

2022. 12. 13. 17:41Post

977. Squares of a Sorted Array

class Solution(object):
    def sortedSquares(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """

        # 모두 절대값으로 만든다
        # 정렬한다
        # 정렬한것을 제곱한다
        # 리턴한다
        abs_list = list(map(abs, nums))
        abs_list.sort()
        square_list = list(map(lambda x:pow(x,2),abs_list))
        return square_list