diff --git a/problems/0977.有序数组的平方.md b/problems/0977.有序数组的平方.md index 20bdf7b0..ee7a1941 100644 --- a/problems/0977.有序数组的平方.md +++ b/problems/0977.有序数组的平方.md @@ -41,6 +41,15 @@ public: } }; ``` +```python3 +class Solution: + def sortedSquares(self, nums: List[int]) -> List[int]: + res=[] + for num in nums: + res.append(num**2) + return sorted(res) +``` + 这个时间复杂度是 O(n + nlogn), 可以说是O(nlogn)的时间复杂度,但为了和下面双指针法算法时间复杂度有鲜明对比,我记为 O(n + nlog n)。