mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Update 0977.有序数组的平方.md
python3 version of brutal force
This commit is contained in:
@ -39,6 +39,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