Skip to content

Commit

Permalink
#12 23.10.25 > 문자열 내 마음대로 정하기 다시풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Oct 25, 2023
1 parent b794c86 commit cf1df56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/programmers/Lv_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
| 46 | [완주하지 못한 선수](./notCompletion.js) | 22.06.26 | O | X |
| 47 | [두 개 뽑아서 더하기](./popTwoSum.js) | 22.06.26 | O | [23.10.25](./replay/popTowsum.js) |
| 48 | [비밀 지도](./secretMap.js) | 22.06.27 | X | 다시풀었음 |
| 49 | [문자열 내 마음대로 정하기](./asonelikes.js) | 22.06.28 | X | 다시 풀었음 |
| 49 | [문자열 내 마음대로 정하기](./asonelikes.js) | 22.06.28 | X | [23.10.25](./replay/mymindSort.js) |
| 50 | [하샤드 수](./hashadNumber.js) | 22.06.29 | O | X |
| 51 | [콜라츠 추측](./collatz.js) | 22.06.29 | O | X |
| 52 | [3진법 뒤집기](./reverse3.js) | 22.06.30 | O | X |
Expand Down
27 changes: 27 additions & 0 deletions src/programmers/Lv_1/replay/mymindSort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* [정렬은 정렬인데.. 구현처럼 풀었다]
*/

function solution(strings, n) {
let answer = strings;
for (let i = 0; i < strings.length; i++) {
answer[i] = strings[i][n] + strings[i];
}

answer.sort();
return answer.map((strings) => strings.substring(1));
}

function solution(strings, n) {
let answer = strings;
for (let i = 0; i < strings.length; i++) {
answer[i] = strings[i][n] + strings[i];
}

answer.sort();
for (let i = 0; i < answer.length; i++) {
answer[i] = answer[i].replace(answer[i][0], "");
}

return answer;
}

0 comments on commit cf1df56

Please sign in to comment.