https://school.programmers.co.kr/learn/courses/30/lessons/70129
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(s) {
let counter = 0
let zero = 0
let result=0
while(result!=1) {
let arr =[]
if(!counter){
arr = s.split('')
}else{
arr=result.split('')
}
let count =0
arr.forEach((num)=>{
if(num==0){
count ++
zero ++
}
})
counter ++
result = (arr.length - count).toString(2)
}
return [counter,zero];
}
'코테' 카테고리의 다른 글
LeetCode Top Interview 150 - 27. Remove Element (0) | 2023.08.23 |
---|---|
LeetCode Top Interview 150 - 88. Merge Sorted Array (0) | 2023.08.22 |
코테 - 완전탐색 - 모의고사 (0) | 2023.07.07 |
코테 - 예산 (0) | 2023.07.04 |
코테 - 연습문제 - 최소값 만들기 (0) | 2023.07.03 |