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
|
36 Discussions
|
Please Login in order to post a comment
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
I whould expect string of different lenght so my sol is more comples than required
Here is A or B problem solution in Python Java C++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-A-or-B-problem-solution.html