Movatterモバイル変換


[0]ホーム

URL:


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

Commit94fd2bf

Browse files
committed
implement quick sort
1 parentf8ab151 commit94fd2bf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎problem/palindromeNum.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
varisPalindrome=function(x){
1+
varisPalindrome=function(x){
22
if(x<0){
33
returnfalse;
44
}

‎sorting/quickSort.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
functionpartition(arr,l,r){
22
letpivot=arr[l];
3+
// count small data
34
letcount=0;
45
for(leti=l;i<=r;i++){
56
if(arr[i]<pivot){
67
count++;
78
}
89
}
10+
console.log(arr);
11+
console.log(count);
12+
console.log(pivot);
13+
14+
lettemp=arr[l];
15+
arr[l]=arr[count];
16+
arr[count]=temp;
917
}
1018

19+
1120
functionquickSort(arr,l,r){
1221
if(l<r){
1322
letp=partition(arr,l,r);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp