mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 02:53:31 +08:00
@ -96,7 +96,6 @@ public:
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
|
||||
Java:
|
||||
```Java
|
||||
class Solution {
|
||||
@ -119,6 +118,25 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
class Solution {
|
||||
public int[] sortedSquares(int[] nums) {
|
||||
int l = 0;
|
||||
int r = nums.length - 1;
|
||||
int[] res = new int[nums.length];
|
||||
int j = nums.length - 1;
|
||||
while(l <= r){
|
||||
if(nums[l] * nums[l] > nums[r] * nums[r]){
|
||||
res[j--] = nums[l] * nums[l++];
|
||||
}else{
|
||||
res[j--] = nums[r] * nums[r--];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Python:
|
||||
```Python
|
||||
class Solution:
|
||||
|
Reference in New Issue
Block a user