leetcode 477. Total Hamming Distance

Orignal question can be found here.

My solution is as follows:

```int totalHammingDistance(int* nums, int numsSize)
{
int result = 0;
int num_of_1 = 0;
for(int i=1; i<31; ++i)
{
num_of_1 = 0;
for(int j=0; j<numsSize; ++j)
{
if(nums[j]%2 == 1)
++ num_of_1;
nums[j] /= 2;
}
result += num_of_1 * (numsSize-num_of_1);
}
return result;
}
```

Chinese docker mirror

Chinese people suffer from a very poor connection to the docker hub. It would take a loooooong time to pull an image from it.

USTC comes to the rescue, it has a docker hub mirror there. All you have to do is to edit you docker configuration file. Also it hosts all the major GNU/Linux distributions.

Thanks to USTC, and happy pulling!

leetcode 169. Majority Element

Orignal question can be found here.

My solution is as follows:

```int majorityElement(int* nums, int numsSize)
{
int cnt=0;
int result=0;
for(int i=0; i<numsSize; ++i)
{
if(cnt==0)
{
result=nums[i];
++cnt;
continue;
}
else
{
if(result==nums[i])
++cnt;
else
--cnt;
}
}
return result;
}
```

leetcode 343. Integer Break

Orignal question can be found here.

My solution is as follows:

```int integerBreak(int n)
{
int result=0;
int new_result=0;
for(int cnt=2; cnt<=n; ++cnt)
{
new_result=pow((n/cnt+1), n%cnt) * pow(n/cnt,(cnt-n%cnt));
if( new_result > result)
result=new_result;
else
break;
}
return result;
}
```

leetcode 100. Same Tree

Orignal question can be found here.

My solution is as follows:

```bool isSameTree(struct TreeNode* p, struct TreeNode* q)
{
if(p==NULL && q==NULL)
return true;
if(p==NULL || q==NULL)
return false;
if(p->val==q->val)
{
return (isSameTree(p->left,q->left) && isSameTree(p->right, q->right));
}

return false;
}
```

leetcode 283. Move Zeroes

Orignal question can be found here.

My solution is as follows:

```void moveZeroes(int* nums, int numsSize)
{
int zero_cnt = 0;
for(int i=0; i<numsSize; ++i)
{
if(nums[i] == 0)
++zero_cnt;
else
nums[i-zero_cnt] = nums[i];
}

for(int i=numsSize-1; i>numsSize-1-zero_cnt; --i)
nums[i] = 0;
}
```

leetcode 226. Invert Binary Tree

Orignal question can be found here.

My solution is as follows:

```struct TreeNode* invertTree(struct TreeNode* root)
{
if(root==NULL)
return root;
else
{
struct TreeNode* left_child=root->left;
struct TreeNode* right_child=root->right;
root->left=right_child;
root->right=left_child;
invertTree(root->left);
invertTree(root->right);
}
return root;
}

```