977. Squares of a Sorted Array

class Solution:
    def sortedSquares(self, A: List[int]) -> List[int]:
        return [x**2 for x in sorted(A, key=lambda x: abs(x))]

Last updated

Was this helpful?