Created
June 9, 2020 07:55
-
-
Save sedera-tax/3d1a63b17d2ea302a9f3837be0d4ae84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function killKthBit($n, $k) { | |
return (strlen(base_convert((string) $n,10,2))-$k >= 0) ? (int) base_convert(substr_replace(base_convert((string) $n,10,2),'0',strlen(base_convert((string) $n,10,2))-$k,1),2,10) : (int) $n; | |
} | |
echo killKthBit(2147483647, 31); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment