#include <iostream>
using namespace std;
int solution(int n)
{
int ans = 0;
while(n > 0)
{
if (n % 2 == 0) n/=2;
else
{
n -= 1;
ans++;
}
}
return ans;
}
문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/12980
'콘솔창 & 윈도우창 > 코딩 테스트' 카테고리의 다른 글
프로그래머스 LV.2 오픈채팅방 (0) | 2025.04.08 |
---|---|
프로그래머스 LV.3 이중우선순위 (0) | 2025.04.07 |
백준 골드4 카드 정렬하기 (0) | 2025.04.06 |
프로그래머스 LV.2 N ^ 2 배열 자르기 (0) | 2025.04.03 |
프로그래머스 LV.2 연속 부분 수열의 합의 개수 (0) | 2025.03.31 |