classSolution:defsortedSquares(self,nums: List[int]) -> List[int]: left =0 right =len(nums)-1 res = []while left <= right:ifabs(nums[left])>abs(nums[right]): res.append(nums[left] **2) left +=1else: res.append(nums[right] **2) right -=1return res[::-1]