摘要: int isPrefixOfWord(char * sentence, char * searchWord){ char* buffer; int pst=1; buffer=strtok(sentence," "); while(buffer){ if(strstr(buffer,searchWo 阅读全文
posted @ 2020-11-27 23:31 温暖了寂寞 阅读(86) 评论(0) 推荐(0) 编辑
摘要: bool CheckPermutation(char* s1, char* s2){ int len1=strlen(s1), len2=strlen(s2); if(len1 != len2) return false; int i, hash[26]={0}; for(i=0; i<len1; 阅读全文
posted @ 2020-11-27 21:26 温暖了寂寞 阅读(61) 评论(0) 推荐(0) 编辑
摘要: int climbStairs(int n){ int i, pre=1, prepre=0, cur=0; for(i=1; i<=n; i++){ cur=pre+prepre; prepre=pre; pre=cur; } return cur; } 阅读全文
posted @ 2020-11-27 21:11 温暖了寂寞 阅读(65) 评论(0) 推荐(0) 编辑
摘要: void dfs(int** image, int imageSize, int colsize, int r, int c, int newColor, int initColor){ if(r<0 || r>=imageSize || c<0 || c>=colsize || image[r][ 阅读全文
posted @ 2020-11-27 19:50 温暖了寂寞 阅读(138) 评论(0) 推荐(0) 编辑
摘要: int getRes(char *str){ int len = strlen(str); char c = 'z'; int ht[26] = {0}; for(int i=0; i<len; i++){ ht[str[i]-'a']++; c = str[i] < c ? str[i] : c; 阅读全文
posted @ 2020-11-27 16:55 温暖了寂寞 阅读(100) 评论(0) 推荐(0) 编辑
摘要: int bitwiseComplement(int N){ int cnt=0, val=0; if(N==0) return 1; while(N){ val += !(N&1)*pow(2,cnt++); N>>=1; } return val; } 阅读全文
posted @ 2020-11-27 12:36 温暖了寂寞 阅读(87) 评论(0) 推荐(0) 编辑
摘要: int maxPower(char * s){ int i, cnt=0, maxLen=0, len=strlen(s); for(i=0; i<len; i++){ cnt++; if(i==len-1 || s[i]!=s[i+1]){ if(cnt>maxLen) maxLen=cnt; c 阅读全文
posted @ 2020-11-27 09:47 温暖了寂寞 阅读(147) 评论(0) 推荐(0) 编辑