class Solution:

    def sortedSquares(self, A):
        left, right = 0, len(A) - 1
        result = []
        while left <= right:
            if abs(A[left]) > abs(A[right]):
                result.append(A[left] * A[left])
                left += 1
            else:
                result.append(A[right] * A[right])
                right -= 1
        return result[::-1]

8d5c8a85bbccaa2b88df965d9b52109991c5cbb5
<mask token>

class Solution:
    <mask token>

class Solution:

    def sortedSquares(self, A):
        left, right = 0, len(A) - 1
        result = []
        while left <= right:
            if abs(A[left]) > abs(A[right]):
                result.append(A[left] * A[left])
                left += 1
            else:
                result.append(A[right] * A[right])
                right -= 1
        return result[::-1]
