Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 722a32c

Browse files
Update 0977.有序数组的平方.md
python3 version of brutal force
1 parent 87abfa1 commit 722a32c

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
@@ -39,6 +39,15 @@ public:
3939
}
4040
};
4141
```
42+
```python3
43+
class Solution:
44+
def sortedSquares(self, nums: List[int]) -> List[int]:
45+
res=[]
46+
for num in nums:
47+
res.append(num**2)
48+
return sorted(res)
49+
```
50+
4251

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /