摘要: bool isPowerOfFour(int num){ return num > 0 && (num & (num - 1))== 0 && (num & 0xaaaaaaaa) == 0; } 阅读全文
posted @ 2020-09-11 18:24 温暖了寂寞 阅读(106) 评论(0) 推荐(0) 编辑
摘要: bool isPowerOfThree(int n){ // for (int i=0; pow(3,i)<=n; i++) // { // if (pow(3,i) == n) return true; // } // return false; return n > 0 && 116226146 阅读全文
posted @ 2020-09-11 17:43 温暖了寂寞 阅读(103) 评论(0) 推荐(0) 编辑
摘要: bool isPowerOfTwo(int n){ for (int i=0; i<31 && pow(2,i)<=n; i++) { if (pow(2,i) == n) return true; } return false; } bool isPowerOfTwo(int n){ return 阅读全文
posted @ 2020-09-11 16:40 温暖了寂寞 阅读(99) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b) { return *(int*)a - *(int*)b; } int* powerfulIntegers(int x, int y, int bound, int* returnSize){ if (bound<2) { 阅读全文
posted @ 2020-09-11 15:31 温暖了寂寞 阅读(177) 评论(0) 推荐(0) 编辑
摘要: bool isprime(int count) { if (count ==1) return false; for (int j=2; j<=sqrt(count); j++) { if(count % j == 0) return false; } return true; } int numP 阅读全文
posted @ 2020-09-11 12:13 温暖了寂寞 阅读(150) 评论(0) 推荐(0) 编辑
摘要: bool isprime(int count) { if (count ==1) return false; for (int j=2; j<=sqrt(count); j++) if(count % j == 0) return false; return true; } int countPri 阅读全文
posted @ 2020-09-11 11:27 温暖了寂寞 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #include <semaphore.h> class Foo { protected: sem_t firstJobDone; sem_t secondJobDone; public: Foo() { sem_init(&firstJobDone, 0, 0); sem_init(&second 阅读全文
posted @ 2020-09-11 10:08 温暖了寂寞 阅读(119) 评论(0) 推荐(0) 编辑
摘要: char * reverseOnlyLetters(char * S){ int len = strlen(S); int left=0,right=len-1; char ch; while(left<right) { if (isalpha(S[left]) && isalpha(S[right 阅读全文
posted @ 2020-09-11 09:27 温暖了寂寞 阅读(113) 评论(0) 推荐(0) 编辑
摘要: struct ListNode* reverseList(struct ListNode* head){ if(!head || !head->next) return head; struct ListNode *res = reverseList(head->next); head->next- 阅读全文
posted @ 2020-09-11 08:58 温暖了寂寞 阅读(146) 评论(0) 推荐(0) 编辑