레벨2 큰 수 만들기

이성훈·2021년 10월 23일
0

알고리즘

목록 보기
2/12

문제

풀이

// ! 내 코드
function solution(number, k) {
  const stack = [];

  console.log(number.split(""));
  number.split("").forEach((el) => {
    while (k > 0 && stack[stack.length - 1] < el) {
      stack.pop();
      k--;
    }

    stack.push(el);
  });

  stack.splice(stack.length - k, k);

  return stack.join("");
}
profile
블로그 이전중입니다 => https://kusdsuna.tistory.com/

0개의 댓글