Level 0. 1로 만들기
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int solution(vector<int> num_list)
{
auto func = [](int sum, int num)
{
int n = 0;
while (num >>= 1)
++n;
return sum + n;
};
return accumulate(num_list.begin(), num_list.end(), 0, func);
}
'자료구조 & 알고리즘 > 프로그래머스' 카테고리의 다른 글
Level 0. 특별한 이차원 배열 1 (0) | 2023.05.28 |
---|---|
Level 0. 조건 문자열 (0) | 2023.05.27 |
Level 0. 배열 만들기 5 (0) | 2023.05.25 |
Level 0. 문자 개수 세기 (0) | 2023.05.24 |
Level 2. 연속된 부분 수열의 합 (0) | 2023.05.23 |