mam what does mod do in these vedio
Unique number 3 problem
each bit should be present in a multiple of three since if a number is repeated thrice, its contribution has to be three and same for all numbers but the number that will not be repeated thrice will give only 1 as contribution to that bit
so what the mod does is that it gives the count
can i say there are two possibilites only
either this bit is a multiple of 3, that means this bit is only set for all numbers which are repeated thrice
i.e. 3n for some n, so 3n%n gives the remainder when 3n is divided by n which is 0, which means this bit is not set in the required number
second possibility on similar lines is that this bit’s count will be one extra than a multiple of three
which is 3n+1 and (3n+1)%3 = 1 which is the remainder
which means this bit is set in the req number
so that is the use of %