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 f659c18 + 1396008 commit ca2e8aaCopy full SHA for ca2e8aa
problems/0977.有序数组的平方.md
@@ -96,7 +96,6 @@ public:
96
97
## 其他语言版本
98
99
-
100
Java:
101
```Java
102
class Solution {
@@ -119,6 +118,25 @@ class Solution {
119
118
}
120
```
121
+```java
122
+class Solution {
123
+ public int[] sortedSquares(int[] nums) {
124
+ int l = 0;
125
+ int r = nums.length - 1;
126
+ int[] res = new int[nums.length];
127
+ int j = nums.length - 1;
128
+ while(l <= r){
129
+ if(nums[l] * nums[l] > nums[r] * nums[r]){
130
+ res[j--] = nums[l] * nums[l++];
131
+ }else{
132
+ res[j--] = nums[r] * nums[r--];
133
+ }
134
135
+ return res;
136
137
+}
138
+```
139
+
140
Python:
141
```Python
142
class Solution:
0 commit comments