From cf1df56357d9cdea06c9334f5ceedb57f2b1faf3 Mon Sep 17 00:00:00 2001 From: beurmuz Date: Wed, 25 Oct 2023 20:18:13 +0900 Subject: [PATCH] =?UTF-8?q?#12=2023.10.25=20>=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=EC=97=B4=20=EB=82=B4=20=EB=A7=88=EC=9D=8C=EB=8C=80=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B8=B0=20=EB=8B=A4=EC=8B=9C=ED=92=80?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/programmers/Lv_1/README.md | 2 +- src/programmers/Lv_1/replay/mymindSort.js | 27 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/programmers/Lv_1/replay/mymindSort.js diff --git a/src/programmers/Lv_1/README.md b/src/programmers/Lv_1/README.md index 2b7ee62f..bd3e4ab6 100644 --- a/src/programmers/Lv_1/README.md +++ b/src/programmers/Lv_1/README.md @@ -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 | diff --git a/src/programmers/Lv_1/replay/mymindSort.js b/src/programmers/Lv_1/replay/mymindSort.js new file mode 100644 index 00000000..87ce2e02 --- /dev/null +++ b/src/programmers/Lv_1/replay/mymindSort.js @@ -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; +}