leetcode Missing Number

Use the sumup of all the number subtract the sum of them.

int missingNumber(int* nums, int numsSize) {
long long int sum = 0;
for(int i = 0;i < numsSize;++ i) sum += nums[i];
return (numsSize + 1) * numsSize / 2 - sum;

leetcode Ugly Number II

This is not a difficult one.
Basic idea is, assum that we have a self-sorted queue. Everytime, we choose the smallest one n, insert 2*n , 3*n , 5*n into this queue. After n times, we will get the n-th Ugly number.
The time will be $O(nlogn)$. Do we have a better way? The answer is YES!

Tower of Hanoi

I’m so tierd and upset today. I want to practise a DFS, BFS and a recursive.
I find it’s easy for me to write a BFS or DFS. So I just wrote a Hanoi tower.
It’s a very basic algorithm. This is my code.

Heap insertion and deletion in C

It’s a program about basic insertion and deletion of a heap.(include heapify)
It’s insertion and deletion time complexity is $O(logn)$
Once I finished this code and began to run, it runs without bug.
Which means I finished this code Without any debuging~
I spent half an hour to write this program
This is a small top heap