Merge pull request #1424 from Cwlrin/master

添加(0027.移除元素.md、0977.有序数组的平方.md):增加 C# 版本
This commit is contained in:
程序员Carl
2022-07-06 09:27:50 +08:00
committed by GitHub
2 changed files with 34 additions and 3 deletions

View File

@@ -420,6 +420,24 @@ object Solution {
}
```
C#
```csharp
public class Solution {
public int[] SortedSquares(int[] nums) {
int k = nums.Length - 1;
int[] result = new int[nums.Length];
for (int i = 0, j = nums.Length - 1;i <= j;){
if (nums[i] * nums[i] < nums[j] * nums[j]) {
result[k--] = nums[j] * nums[j];
j--;
} else {
result[k--] = nums[i] * nums[i];
i++;
}
}
return result;
}
}
```
-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>