set_kth_bit {
44std ::int64_t k) {
// int64_t is preferred over int so 45 // that no Overflow can be there. 481 << k;
// "pos" variable is used to store 1 at kth postion and 49 // rest bits are 0. in binary representation of number 'n' 51 returnN | pos;
// by taking or with the pos and the N we set the bit of N 54}
// namespace set_kth_bit 55}
// namespace bit_manipulation 66 // n = 400001,5 return 400033 71std::cout <<
"All test cases successfully passed!"<< std::endl;
78 test();
// run self-test implementationsFunctions for the [From the right, set the Kth bit in the binary representation of N] (https://practi...
static void test()
Self-test implementations.
std::uint64_t setKthBit(std ::int64_t N, std ::int64_t k)
The main function implements set kth bit.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4