Cody and higher algebra

this is the problem on hackerblocks on the topic bitmasking can anyne explain it?

Hi!

In this problem, you’re given an array in which all numbers occurs 3 times except one number that occurs only once.
For Example: 7,7,3,4,2,4,3,3,4,7
In the above array 7,3 and 4 occur thrice, but 2 occurs only one time. Your job is to find the unique number(i.e. 2 in this case)
HINT: To solve this question, you can add the respective bits of numbers and then take modulo 3 to get the answer.
For Example: let 2,3,2,7,2,7,7 be the array
then binary rep of 2 = |1|0|
binary rep of 3 = |1|1|
Binary rep of 7 = |1|1|1|
let us say you store the sum in sum array:
sum = |3|7|4|
sum%3= |0|1|1|
i.e 3

it is not unique no 3 it is Cody and higher algebra on hackerblocks

let me see that, I got Unique Number-3 as the question, hence explained that.

Can you share the link to the problem, because you have raised the doubt against Unique Number-3 and that’s why I can’t find the question

https://hack.codingblocks.com/practice/p/366/497
this is the link of question

Hi!
In this problem you are given a number n as input, you have to output f(n) where f(n) is the Number of solutions to the equation
x+y+z=n
such that

  1. x, y, z >= 0
  2. (x & y & z) > 0 where & is bitwise AND

Now, here you have the value of n, you have to find the number of triplets (x,y,z) which can satisfy the above equation and both conditions.

For Eg: For n=3
there can be number of solutions like (3,0,0),(2,1,0),(1,1,1),…
but 3,0,0 and 2,1,0 do NOT satisfy the 2nd condition as 3&0&0 =0, also 2&1&0=0
but 1&1&1 !=0
so 1,1,1 is the solution
hence number of soln =1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.