counting-bits 1.0.0
Counting Bits
Loading...
Searching...
No Matches
Solution Class Reference

Public Member Functions

vector< int > countBits (int n)
 

Detailed Description

Definition at line 5 of file main.cpp.

Member Function Documentation

◆ countBits()

vector< int > Solution::countBits ( int  n)
inline

Definition at line 8 of file main.cpp.

9 {
10 vector<int> answer(n + 1, 0);
11
12 for (int i = 0; i <= n; ++i)
13 answer[i] = answer[i >> 1] + (i & 1);
14
15 return answer;
16 }

Referenced by main().


The documentation for this class was generated from the following file: