Total Hamming Distance

  • 0

    Click here to see the full article post

  • 0

    "We know that the count of such unique pairs is kC1∗n−kC1=k⋅(n−k){}^kC_1 * {}^{n-k}C_1 = k \cdot (n-k)​k​​C​1​​∗​n−k​​C​1​​=k⋅(n−k) for this particular bit."....can you please help understand reasoning for it? The way I see it, if there're k numbers which have "ith" bit set, there're (n-k) numbers which have "ith" bit unset. Pair each of those k numbers with each of (n-k) numbers - there're total of k * (n-k) pairs. Each such pair contributes hamming distance of 1

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.