From 1a66a8103f25f0267276bf9b9386f5c893a2fe9a Mon Sep 17 00:00:00 2001 From: suKyoung Date: Tue, 28 Oct 2025 15:50:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?add:=20=EC=A0=90=EC=88=98=EA=B3=84=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\220\354\210\230\352\263\204\354\202\260.js" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "src/inflearn_coding_test/basic/2-4_\354\240\220\354\210\230\352\263\204\354\202\260.js" diff --git "a/src/inflearn_coding_test/basic/2-4_\354\240\220\354\210\230\352\263\204\354\202\260.js" "b/src/inflearn_coding_test/basic/2-4_\354\240\220\354\210\230\352\263\204\354\202\260.js" new file mode 100644 index 0000000..e02b322 --- /dev/null +++ "b/src/inflearn_coding_test/basic/2-4_\354\240\220\354\210\230\352\263\204\354\202\260.js" @@ -0,0 +1,17 @@ +function solution(arr) { + let answer = 0; + let count = 0; + + for (const curr of arr) { + if (curr === 1) { + answer += curr + count; + count++; + } else { + count = 0; + } + } + + return answer; +} + +console.log(solution([1, 0, 1, 1, 1, 0, 0, 1, 1, 0])); From 8cda13579303b59323a2c96074f11ff664ec8481 Mon Sep 17 00:00:00 2001 From: suKyoung Date: Tue, 28 Oct 2025 19:12:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?add:=20=EB=93=B1=EC=88=98=EA=B5=AC=ED=95=98?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...10\230\352\265\254\355\225\230\352\270\260.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "src/inflearn_coding_test/basic/2-5_\353\223\261\354\210\230\352\265\254\355\225\230\352\270\260.js" diff --git "a/src/inflearn_coding_test/basic/2-5_\353\223\261\354\210\230\352\265\254\355\225\230\352\270\260.js" "b/src/inflearn_coding_test/basic/2-5_\353\223\261\354\210\230\352\265\254\355\225\230\352\270\260.js" new file mode 100644 index 0000000..208a678 --- /dev/null +++ "b/src/inflearn_coding_test/basic/2-5_\353\223\261\354\210\230\352\265\254\355\225\230\352\270\260.js" @@ -0,0 +1,15 @@ +function solution(arr) { + const answer = Array.from({ length: arr.length }, () => 1); + + for (let i = 0; i < arr.length; i++) { + for (let j = 0; j < arr.length; j++) { + if (i === j) continue; + if (arr[i] < arr[j]) answer[i]++; + } + } + + return answer; +} + +console.log(solution([87, 89, 92, 100, 76])); // 4 3 2 1 5 +console.log(solution([95, 99, 99, 98, 100])); // 5,2,2,4,1