Question on Leetcode - Easy
The approach to this question looks straighforward and simple at first. I'm returning the list pf squared arrays using sorted(). Should solve better tomorrow.
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
return sorted([x ** 2 for x in nums])
- Time complexity: O(n)
- Space complexity: O(1)