<filename>two_pointer/leetcdoe_977_hayeon.py
class Solution:
    def sortedSquares(self, nums: List[int]) -> List[int]:
        answer = [0 for i in range(len(nums))]
        left,right = 0, len(nums) - 1
        current_index = right
        while left <= right:
            if nums[left]**2 <= nums[right]**2:
                answer[current_index] = nums[right]**2
                right -= 1
            else:
                answer[current_index] = nums[left]**2
                left += 1
            current_index -= 1
        return answer

<filename>two_pointer/leetcdoe_977_hayeon.py
class Solution:
    def sortedSquares(self, nums: List[int]) -> List[int]:
        answer = [0 for i in range(len(nums))]
        left,right = 0, len(nums) - 1
        current_index = right
        while left <= right:
            if nums[left]**2 <= nums[right]**2:
                answer[current_index] = nums[right]**2
                right -= 1
            else:
                answer[current_index] = nums[left]**2
                left += 1
            current_index -= 1
        return answer
