We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is quick hack for gcc __builtin_popcount function. There is NO __builtin_popcount in c++, it's a built in function of GCC.
The function prototype is as follows:
int__builtin_popcount(unsignedint)
though there are additional implementations of this function for long and long long types.
It returns the numbers of bits in an integer (the number of ones in the binary representation of the integer).
This function tries to use CPU specific instructions, which will always be orders of magnitude faster than any algorithm you manage to come up with.
Since this is highly compiler specific implementation and here we do reference implementations rather then production ones I proposed to use the builtin replacement for the CassioNeri implementation (gcc specific).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Bit Array
You are viewing a single comment's thread. Return to all comments →
This is quick hack for gcc __builtin_popcount function. There is NO __builtin_popcount in c++, it's a built in function of GCC.
The function prototype is as follows:
though there are additional implementations of this function for long and long long types.
It returns the numbers of bits in an integer (the number of ones in the binary representation of the integer).
This function tries to use CPU specific instructions, which will always be orders of magnitude faster than any algorithm you manage to come up with.
Since this is highly compiler specific implementation and here we do reference implementations rather then production ones I proposed to use the builtin replacement for the CassioNeri implementation (gcc specific).