Counting of set bits

In python there is a function bin() which gives binary number in type string. Is there a function in c++ which can give me a binary number like python?

what is _builtin_popcount time complexity?

In C++, you can use bitset for this purpose.

https://stackoverflow.com/questions/22746429/c-decimal-to-binary-converting#:~:text=You%20can%20use%20std%3A%3A,(n).

It must be O(no of set bits). So you can say constant time complexity. Maxm number of set bits can be 32(if integer)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.