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.
I wrote efficient functions for doing these specific queries over a bit-packed array in C++14. The slowest executing test took 0.44s.
I also wrote a much easier solution that uses vector(char) and doesn't bit-pack. It only took a couple minor optimizations to the hamming distance and print functions and it executed the slowest test at around 1.9s - just barely fast enough, I wonder if that was even "supposed" to work. The constraints on N and M aren't enough to force the use of bitpacking it seems.
Another funny thing - vector(bool) performed worse than vector (char).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hamming Distance
You are viewing a single comment's thread. Return to all comments →
I wrote efficient functions for doing these specific queries over a bit-packed array in C++14. The slowest executing test took 0.44s.
I also wrote a much easier solution that uses vector(char) and doesn't bit-pack. It only took a couple minor optimizations to the hamming distance and print functions and it executed the slowest test at around 1.9s - just barely fast enough, I wonder if that was even "supposed" to work. The constraints on N and M aren't enough to force the use of bitpacking it seems.
Another funny thing - vector(bool) performed worse than vector (char).