Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def sortedSquares(self, nums: List[int]) -> List[int]:
- result = []
- start = 0
- end = len(nums) - 1
- while start<=end:
- if abs(nums[start]) > abs(nums[end]):
- result.append(nums[start]**2)
- start += 1
- else:
- result.append(nums[end]**2)
- end -= 1
- return result[::-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement