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.
- Prepare
- C++
- Other Concepts
- Bit Array
- Discussions
Bit Array
Bit Array
Sort by
recency
|
297 Discussions
|
Please Login in order to post a comment
I don't understand all the complicated solutions here. There is someone talking about overflow being well defined in C++ for unsigned types, and there happens to be a common 32bit unsigned integer type usually available in
unsigned int
. So my simple solution which passes all tests seems best.Unfair! The same code is passing with C++ 11 but not with C++ 14 (time outing some cases).
The hackerrrank gotta fix their compilers!
tortise and hare doesn't make any sense... When the data is not stored up in any structure, the time is enough for just purely comparison and increment count accordingly.
I solved it and explained in a GitHub repository, enjoy :) https://github.com/IvanPinna/BitArray-Hackerrank
As we are constantly doing % 2^31, and given that unsigned overflow behavior is well defined in c++, is there any point in using long long (64bits) types?