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 d142177 + 50a52af commit 2db3b57Copy full SHA for 2db3b57
csharp/0075-sort-colors.cs
@@ -0,0 +1,28 @@
1
+public class Solution {
2
+ public void SortColors(int[] nums) {
3
+ int low = 0;
4
+ int high = nums.Length - 1;
5
+ int mid = 0;
6
+
7
+ while (mid <= high) {
8
+ switch (nums[mid]) {
9
+ case 0:
10
+ int temp0 = nums[low];
11
+ nums[low] = nums[mid];
12
+ nums[mid] = temp0;
13
+ low++;
14
+ mid++;
15
+ break;
16
+ case 1:
17
18
19
+ case 2:
20
+ int temp2 = nums[mid];
21
+ nums[mid] = nums[high];
22
+ nums[high] = temp2;
23
+ high--;
24
25
+ }
26
27
28
+}
0 commit comments