Over 100 ms.. c'mon
Over 100 ms.. c'mon
Though they are almost the same , the bit manipulation tends to perform better under a higher magnitude of data input
Though they are almost the same , the bit manipulation tends to perform better under a higher magnitude of data input
def reversed(x: int) -> int:
num = 0
for _ in range (512):
num = (num << 1) | (x & 1)
x >>= 1
return num
though, it is longer but is faster than having to convert num to binary string and then reverse it becs it directly manipulates the individual bits.
I may be wrong
def reversed(x: int) -> int:
num = 0
for _ in range (512):
num = (num << 1) | (x & 1)
x >>= 1
return num
though, it is longer but is faster than having to convert num to binary string and then reverse it becs it directly manipulates the individual bits.
I may be wrong
Python built in l support for bit manipulation is way much faster than the string manipulation
Especially working with large amount of data
Python built in l support for bit manipulation is way much faster than the string manipulation
Especially working with large amount of data
Obviously not faster
Obviously not faster