Proof with explanation | Simple Intuition
In this problem if we fix a particular number then can we predict anothe number ?\n\nConvert the question into two cases:\n1. Non Overlapping Case: (Means the n
In this problem if we fix a particular number then can we predict anothe number ?\n\nConvert the question into two cases:\n1. **Non Overlapping Case**: (Means the number of set bits are not overlapping):\n       N1 = 1010101\n\t   N2 = 0101010\n\tAND = 0000000  (Since Overlapping is zero)\n\tOR   = 11111111 \n\tSuppose **if number of set bits in N1 are n1 and number of set bits in N2 are n2** then in above non overlapping case AND = 0 and OR = n1 + n2:\n\tSo -> AND + OR = n1 + n2  ..... (1)\n\t\n2. **Overlapping Case**:(Means the number of set bits are overlapping):\n       N1 = 101110100\n\t   N2 = 001010101\n\t   \n  AND = overlapping set bits \n  OR = n1 + n2 - (overlapping set bits)\n  \n  If we add both of them then :\n     AND + OR = n1 + n2   ....  (2)\n\t \n-> From equation 1 and 2 we can deduce that the summation of AND and OR only depends on the number of set bits in number 1 and number of set bits in number 2.\n\nNow u can follow this code : \nCode: \nhttps://leetcode.com/contest/weekly-contest-303/submissions/detail/755078727/\n\nhttps://leetcode.com/problems/number-of-excellent-pairs/discuss/2324745/c\n\n\t \n\t   \n\n\n\n\n\n\n
[]