Skip to content

Commit

Permalink
#7 22.10.30 > 삽입 정렬
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Oct 30, 2022
1 parent f6510c2 commit 4a0d2c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/inf/sort,greedy/4_rere.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";

function solution(arr) {
let answer = arr;
for (let i = 0; i < arr.length; i++) {
let tmp = arr[i],
j;
for (j = i - 1; j >= 0; j--) {
if (arr[j] > tmp) {
arr[j + 1] = arr[j];
} else {
break;
}
}
arr[j + 1] = tmp;
}
return answer;
}

let arr = [11, 7, 5, 6, 10, 9];
console.log(solution(arr));
2 changes: 1 addition & 1 deletion src/inf/sort,greedy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
| 1 | O | 22.10.29 |
| 2 | O | 22.10.30😥 |
| 3 | O | 22.10.30 |
| 4 | X | O |
| 4 | X | 22.10.30😥 |
| 5 | 몰라몰라몰라 | |
| 6 | O | O |
| 7 || O |
Expand Down

0 comments on commit 4a0d2c7

Please sign in to comment.