Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 개발자
- 세션
- 파일 저장
- n^2 배열 자르기
- 유튜브
- javascript
- 프로그래머스
- 메모장
- js
- jdbc
- jsp
- Python
- 자바스크립트
- 크롤링
- 입출력
- 파이썬
- 이진 변환 반복하기
- 형태소 분석기
- android
- 셀레니움
- MySQL
- 개발
- 프로그래밍
- 데이터베이스
- Programmers
- 자바
- 코딩
- 함수형 인터페이스
- java
- 모바일
Archives
- Today
- Total
개인용 복습공간
프로그래머스 - 이진 변환 반복하기 본문
toString으로 이진 변환
function solution(s) {
let delemination = 0, trans = 0, cnt = 0;
while(s != 1){
delemination += s.replace(/1/g, '').length;
trans = s.replace(/0/g, '').length;
s = trans.toString(2);
cnt++;
}
return [cnt, delemination];
}
'programmers' 카테고리의 다른 글
프로그래머스 - n^2 배열 자르기 (0) | 2023.10.25 |
---|---|
프로그래머스 - 크레인 인형뽑기 게임 (0) | 2023.10.25 |
프로그래머스 - 키패드 누르기 (0) | 2023.10.12 |
프로그래머스 - H-Index (JavaScript, js) (0) | 2023.10.12 |
Comments