We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 65f5430 + 0b82714 commit e718d9bCopy full SHA for e718d9b
problems/0977.有序数组的平方.md
@@ -181,6 +181,17 @@ class Solution:
181
### Go:
182
183
```Go
184
+// 排序法
185
+func sortedSquares(nums []int) []int {
186
+ for i, val := range nums {
187
+ nums[i] *= val
188
+ }
189
+ sort.Ints(nums)
190
+ return nums
191
+}
192
+```
193
+```Go
194
+// 双指针法
195
func sortedSquares(nums []int) []int {
196
n := len(nums)
197
i, j, k := 0, n-1, n-1
0 commit comments