Skip to content

Commit

Permalink
#7 22.11.01 > 장난꾸러기 현수 다시풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Nov 1, 2022
1 parent 612a54f commit bc253e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/inf/sort,greedy/6_rere.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

function solution(arr) {
let answer = [];
let sortArr = arr.slice();
sortArr.sort((a, b) => a - b);
console.log(sortArr);
let sortedArr = arr.slice(); // slice로 배열을 복사하지 않으면 원본 배열도 함께 변화함
sortedArr.sort((a, b) => a - b);

for (let i = 0; i < arr.length; i++) {
if (arr[i] !== sortArr[i]) {
if (arr[i] !== sortedArr[i]) {
answer.push(i + 1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/inf/sort,greedy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| 3 | O | 22.10.30 |
| 4 | X | 22.10.30😥 |
| 5 | 몰라몰라몰라 | |
| 6 | O | 22.10.31 |
| 6 | O | 22.11.01 |
| 7 || O |
| 8 || O |
| 9 || O |
Expand Down

0 comments on commit bc253e8

Please sign in to comment.