728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181880
📝 나의 풀이
using System;
public class Solution {
public int solution(int[] num_list) {
int answer = 0;
for(int i=0; i<num_list.Length; i++){
int num = num_list[i];
while(1<num){
if(num%2==0){
num = num/2;
answer++;
} else {
num = (num-1)/2;
answer++;
}
}
}
return answer;
}
}
728x90
'코딩테스트 > [C#] 프로그래머스' 카테고리의 다른 글
[프로그래머스 | C# | Lv.0] 특별한 이차원 배열 2 (0) | 2023.09.20 |
---|---|
[프로그래머스 | C# | Lv.0] 배열의 원소 삭제하기 (0) | 2023.09.20 |
[프로그래머스 | C# | Lv.0] ad 제거하기 (0) | 2023.09.19 |
[프로그래머스 | C# | Lv.0] 로그인 성공? (0) | 2023.09.19 |
[프로그래머스 | C# | Lv.0] 문자열 정렬하기 (1) (0) | 2023.09.18 |