上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 63 下一页
摘要: char pairs(char a) { if (a == '}') return '{'; if (a == ']') return '['; if (a == ')') return '('; return 0; } bool isValid(char* s) { int n = strlen( 阅读全文
posted @ 2020-08-26 20:10 温暖了寂寞 阅读(124) 评论(0) 推荐(0) 编辑
摘要: . /* 1 = 1; 4 = 1 + 3; 9 = 1 + 3 + 5; 16 = 1 + 3 + 5 + 7; */ 计算过程只需要加减法,效率极高。 bool isPerfectSquare(int num){ if (num == 0 ) return false; int i = 1; w 阅读全文
posted @ 2020-08-26 12:00 温暖了寂寞 阅读(175) 评论(0) 推荐(0) 编辑
摘要: bool isAlienSorted(char ** words, int wordsSize, char * order){ if (wordsSize == 1) return true; int i,j,k; for (i=0; i<wordsSize-1; i++) { int len = 阅读全文
posted @ 2020-08-26 11:31 温暖了寂寞 阅读(274) 评论(0) 推荐(0) 编辑
摘要: int numWaterBottles(int numBottles, int numExchange){ int total = 0; int spaceBottels = 0; while(numBottles) { total+=numBottles; spaceBottels = numBo 阅读全文
posted @ 2020-08-26 09:37 温暖了寂寞 阅读(167) 评论(0) 推荐(0) 编辑
摘要: bool wordPattern(char * pattern, char * str){ char **hash = (char **)malloc(26 * sizeof(char*)); for (int i = 0; i < 26; ++i) { hash[i] = (char*)mallo 阅读全文
posted @ 2020-08-26 00:03 温暖了寂寞 阅读(160) 评论(0) 推荐(0) 编辑
摘要: //的确不用判断x与y的大小关系 int gcd(int x,int y){ if(y==0) return x; return gcd(y,x%y); } bool hasGroupsSizeX(int* deck, int deckSize){ if (deck == NULL || deckS 阅读全文
posted @ 2020-08-25 18:48 温暖了寂寞 阅读(160) 评论(0) 推荐(0) 编辑
摘要: double* twoSum(int n, int* returnSize){ int dp[15][70] = {0}; //赋予初始值,只有一个骰子的时候1到6出现的频率均为1 for (int i = 1; i <= 6; i ++) { dp[1][i] = 1; } //从两个骰子的情况开 阅读全文
posted @ 2020-08-25 13:33 温暖了寂寞 阅读(203) 评论(0) 推荐(0) 编辑
摘要: int add(int a, int b){ while(a!=0){ int temp=a^b; a=((unsigned int)(a&b)<<1); b=temp; } return b; } 阅读全文
posted @ 2020-08-25 08:59 温暖了寂寞 阅读(136) 评论(0) 推荐(0) 编辑
摘要: struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) { struct ListNode *posA = headA; struct ListNode *posB = headB; i 阅读全文
posted @ 2020-08-24 20:51 温暖了寂寞 阅读(146) 评论(0) 推荐(0) 编辑
摘要: int count; void fun(struct TreeNode* node,int* arr) { if (!node) return; arr[count++] = node->val; fun(node->left,arr); fun(node->right,arr); } int My 阅读全文
posted @ 2020-08-24 14:15 温暖了寂寞 阅读(201) 评论(0) 推荐(0) 编辑
上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 63 下一页