摘要: 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) 编辑