摘要: /*递归*/ void func(struct Node* root, int* arr,int* returnSize) { for (int i=0; i<root->numChildren; i++) { func(root->children[i],arr,returnSize); } ar 阅读全文
posted @ 2020-09-15 20:18 温暖了寂寞 阅读(137) 评论(0) 推荐(0) 编辑
摘要: /*递归*/ void func(struct Node* root, int* arr,int* returnSize) { arr[(*returnSize)++] = root->val; for (int i=0; i<root->numChildren; i++) { func(root- 阅读全文
posted @ 2020-09-15 17:57 温暖了寂寞 阅读(151) 评论(0) 推荐(0) 编辑
摘要: int tribonacci(int n){ if (n == 0) return 0; else if (n == 1 || n == 2) return 1; int t0=0, t1=1,t2=1,i,num=0; for (i=3; i<=n; i++) { num = t0 + t1 + 阅读全文
posted @ 2020-09-15 17:06 温暖了寂寞 阅读(99) 评论(0) 推荐(0) 编辑
摘要: int* nextGreaterElement(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize){ int hash[10000] = {0}; int i,j; for (i=0; i<nums2Size; 阅读全文
posted @ 2020-09-15 16:33 温暖了寂寞 阅读(115) 评论(0) 推荐(0) 编辑
摘要: bool canWinNim(int n){ return n % 4; } 阅读全文
posted @ 2020-09-15 15:59 温暖了寂寞 阅读(107) 评论(0) 推荐(0) 编辑
摘要: bool checkPossibility(int* nums, int numsSize){ int count=0,i; for (i=1; i<numsSize-1; i++) { if (i==1 && nums[i-1] > nums[i]) { nums[i-1] = nums[i]; 阅读全文
posted @ 2020-09-15 14:58 温暖了寂寞 阅读(146) 评论(0) 推荐(0) 编辑
摘要: int findComplement(int num){ int sum =0,pst=0; while(num){ if ((num & 1) == 0) { sum += pow(2,pst); } num >>= 1; pst++; } return sum; } 阅读全文
posted @ 2020-09-15 13:35 温暖了寂寞 阅读(149) 评论(0) 推荐(0) 编辑
摘要: int hammingWeight(uint32_t n) { int count=0; while(n) { if(n & 1) count++; n >>= 1; } return count; } 阅读全文
posted @ 2020-09-15 12:31 温暖了寂寞 阅读(113) 评论(0) 推荐(0) 编辑
摘要: int compare(const void* a, const void* b) { return *(int*)a > *(int*)b; } int numberOfBoomerangs(int** points, int pointsSize, int* pointsColSize) { i 阅读全文
posted @ 2020-09-15 11:58 温暖了寂寞 阅读(203) 评论(0) 推荐(0) 编辑