mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Merge pull request #3 from janeyziqinglin/janeyziqinglin-patch-3
Update 0977.有序数组的平方 python版本
This commit is contained in:
@ -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)。
|
||||
|
||||
|
Reference in New Issue
Block a user