Skip to content

Commit e2e7e55

Browse files
Merge pull request #3 from janeyziqinglin/janeyziqinglin-patch-3
Update 0977.有序数组的平方 python版本
2 parents 53e6b96 + 722a32c commit e2e7e55

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

problems/0977.有序数组的平方.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ public:
4141
}
4242
};
4343
```
44+
```python3
45+
class Solution:
46+
def sortedSquares(self, nums: List[int]) -> List[int]:
47+
res=[]
48+
for num in nums:
49+
res.append(num**2)
50+
return sorted(res)
51+
```
52+
4453

4554
这个时间复杂度是 O(n + nlogn), 可以说是O(nlogn)的时间复杂度,但为了和下面双指针法算法时间复杂度有鲜明对比,我记为 O(n + nlog n)。
4655

0 commit comments

Comments
 (0)