Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af5ad21

Browse files
committed
feat: update sync workflow and sync to coding.net
1 parent fa61107 commit af5ad21

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

‎.github/workflows/sync.yml‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Sync to Gitee
11+
- name: Sync to gitee.com
1212
uses: wearerequired/git-mirror-action@master
1313
env:
14-
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
14+
SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }}
1515
with:
1616
source-repo: "git@github.com:doocs/leetcode.git"
1717
destination-repo: "git@gitee.com:Doocs/leetcode.git"
18+
- name: Sync to coding.net
19+
uses: wearerequired/git-mirror-action@master
20+
env:
21+
SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }}
22+
with:
23+
source-repo: "git@github.com:doocs/leetcode.git"
24+
destination-repo: "git@e.coding.net:doocs/leetcode.git"

‎basic/sort/QuickSort.java‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import java.util.Arrays;
2+
3+
public class QuickSort {
4+
5+
private static void quickSort(int[] nums) {
6+
quickSort(nums, 0, nums.length - 1);
7+
}
8+
9+
private static void quickSort(int[] nums, int low, int high) {
10+
if (low >= high) {
11+
return;
12+
}
13+
int[] p = partition(nums, low, high);
14+
quickSort(nums, low, p[0] - 1);
15+
quickSort(nums, p[0] + 1, high);
16+
}
17+
18+
private static int[] partition(int[] nums, int low, int high) {
19+
int less = low - 1, more = high;
20+
21+
while (low < more) {
22+
if (nums[low] < nums[high]) {
23+
swap(nums, ++less, low++);
24+
} else if (nums[low] > nums[high]) {
25+
swap(nums, --more, low);
26+
} else {
27+
++low;
28+
}
29+
}
30+
swap(nums, more, high);
31+
return new int[] {less + 1, more};
32+
}
33+
34+
private static void swap(int[] nums, int i, int j) {
35+
int t = nums[i];
36+
nums[i] = nums[j];
37+
nums[j] = t;
38+
}
39+
40+
public static void main(String[] args) {
41+
int[] nums = {1, 2, 7, 4, 5, 3};
42+
quickSort(nums);
43+
System.out.println(Arrays.toString(nums));
44+
}
45+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /