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
- Algorithms
- Bit Manipulation
- A or B
- Discussions
A or B
A or B
Sort by
recency
|
38 Discussions
|
Please Login in order to post a comment
Haskell
Only half the points -- the others give a non-descript "Runtime Error", which I'd presume is memory. (I checked a few of the missed ones -- the answers are correct.) I'd rewrite it to process chunks, keeping things in the original hex until needed, etc. -- just not for 25 more points today X-)
python3
Simple python solution that follows the methodology described by the editorial
Note: My initial implementation used masks to read and set the bits, but I found this wasn't fast enough for the last 3 tests. Converting to an array and accessing the bits by index proved to be much faster.
Can anyone help me what is wrong with below code? For this particular problem, there could be multiple solutions. void aOrB(int k, char* a, char* b, char* c) { long long num_a, num_b, num_c; //printf("sizeof num_a = %d \n",sizeof(num_a)); num_a = my_atoi(a); num_b = my_atoi(b); num_c = my_atoi(c); /printf("a:%s -->%ld ",a,num_a); printf("b:%s -->0x%x ",b,num_b); printf("c:%s -->0x%x \n",c,num_c);/
question is quite straightforward, but lots of things to consider, and very long code