Hamming Distance Discussions | Algorithms | HackerRank
  • + 0 comments

    In Python3, I've used bin(x).count('1') to calc the hamming distance. C, R and S operations are operatated over a BigInteger converted from the ab string and I think they are sufficiently fast. W operation seems fast enough either.

    At test 21, where 99% of the time is consumed in H operations, this still hits TLE. It takes 16 secs to process 49937 of H operations on my local machine. Google does not give a faster python algo to count bits set to 1 (in x ^ y).

    Has anybody succeeded to pass all the tests in python (without hardcoding)?