上一页 1 ··· 53 54 55 56 57 58 59 60 61 ··· 63 下一页
摘要: int xorOperation(int n, int start){ int val = 0; for (int i=0; i<n; i++) { val ^= start + 2*i; } return val; } 阅读全文
posted @ 2020-08-16 01:12 温暖了寂寞 阅读(116) 评论(0) 推荐(0) 编辑
摘要: int minCount(int* coins, int coinsSize){ int count = 0; for (int i=0; i<coinsSize; i++) { count += coins[i]/2 + coins[i]%2; } return count; } 阅读全文
posted @ 2020-08-15 18:29 温暖了寂寞 阅读(138) 评论(0) 推荐(0) 编辑
摘要: int qusort(int* s,int start,int end) //自定义函数 qusort() { int i,j; //定义变量为基本整型 i= start; //将每组首个元素赋给i j = end; //将每组末尾元素赋给j int k=s[start]; //设置基准值 whil 阅读全文
posted @ 2020-08-15 18:18 温暖了寂寞 阅读(226) 评论(0) 推荐(0) 编辑
摘要: void rotate(int* nums, int numsSize, int k){ k %= numsSize; if (numsSize !=1 && k!=0) { int index = numsSize - k; int* p = (int*)malloc(numsSize*sizeo 阅读全文
posted @ 2020-08-14 19:26 温暖了寂寞 阅读(137) 评论(0) 推荐(0) 编辑
摘要: //异或满足交换律和结合律 int singleNumber(int* nums, int numsSize){ int result = 0; for (int i=0; i<numsSize; i++) result ^= nums[i]; return result; } 阅读全文
posted @ 2020-08-14 16:16 温暖了寂寞 阅读(133) 评论(0) 推荐(0) 编辑
摘要: int mySqrt(int x){ unsigned int i = 0; while(i * i < x) i++; if (i * i == x) return i; return --i; } 阅读全文
posted @ 2020-08-14 14:53 温暖了寂寞 阅读(100) 评论(0) 推荐(0) 编辑
摘要: int getSum(int a, int b){ while(a & b) { unsigned int val_and = a & b; //int val_and = a & b; int val_xor = a ^ b; val_and <<= 1; a = val_and; b = val 阅读全文
posted @ 2020-08-14 13:56 温暖了寂寞 阅读(132) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool IsSym(struct T 阅读全文
posted @ 2020-08-14 11:18 温暖了寂寞 阅读(69) 评论(0) 推荐(0) 编辑
摘要: bool isPalindrome(int x){ if (x < 0) return false; int num = x; int arr[10] = {0}; int index = 0; while(num!=0) { arr[index] = num % 10; num /= 10; in 阅读全文
posted @ 2020-08-13 18:45 温暖了寂寞 阅读(104) 评论(0) 推荐(0) 编辑
摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* nums, int numsSize, int target, int* returnSize){ //i 阅读全文
posted @ 2020-08-13 18:23 温暖了寂寞 阅读(107) 评论(0) 推荐(0) 编辑
上一页 1 ··· 53 54 55 56 57 58 59 60 61 ··· 63 下一页