From 9046df3768c1d648e8fd15bf5caadb5e15ec2824 Mon Sep 17 00:00:00 2001 From: seyoung choi Date: Thu, 8 Jun 2023 22:21:32 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.js" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "programmers/Lv.2/\355\201\260 \354\210\230 \353\247\214\353\223\244\352\270\260/main.js" diff --git "a/programmers/Lv.2/\355\201\260 \354\210\230 \353\247\214\353\223\244\352\270\260/main.js" "b/programmers/Lv.2/\355\201\260 \354\210\230 \353\247\214\353\223\244\352\270\260/main.js" new file mode 100644 index 0000000..e065795 --- /dev/null +++ "b/programmers/Lv.2/\355\201\260 \354\210\230 \353\247\214\353\223\244\352\270\260/main.js" @@ -0,0 +1,12 @@ +function solution(number, k) { + const stack = []; + for (let i = 0; i < number.length; i++) { + while (k > 0 && number[i] > stack[stack.length - 1]) { + stack.pop(); + k--; + } + stack.push(number[i]); + } + + return stack.slice(0, stack.length - k).join(""); +}