摘要: int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } int findContentChildren(int* g, int gSize, int* s, int sSize){ int i=0, j=0, cnt=0; 阅读全文
posted @ 2020-12-01 22:47 温暖了寂寞 阅读(35) 评论(0) 推荐(0) 编辑
摘要: int numRookCaptures(char** board, int boardSize, int* boardColSize){ int cnt = 0, st = 0, ed = 0; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0} 阅读全文
posted @ 2020-12-01 17:54 温暖了寂寞 阅读(93) 评论(0) 推荐(0) 编辑
摘要: double average(int* salary, int salarySize){ int min=1000000,max=1000,i,sum=0; for(i=0; i<salarySize; i++){ if(salary[i]<min) min=salary[i]; if(salary 阅读全文
posted @ 2020-12-01 16:05 温暖了寂寞 阅读(88) 评论(0) 推荐(0) 编辑
摘要: double* averageOfLevels(struct TreeNode* root, int* returnSize){ struct TreeNode* tn[1000]; double* arr=(double*)calloc(1000,sizeof(double)); int left 阅读全文
posted @ 2020-12-01 15:24 温暖了寂寞 阅读(50) 评论(0) 推荐(0) 编辑
摘要: bool backspaceCompare(char* S, char* T) { int i = strlen(S) - 1, j = strlen(T) - 1; int skipS = 0, skipT = 0; while (i >= 0 || j >= 0) { while (i >= 0 阅读全文
posted @ 2020-12-01 14:35 温暖了寂寞 阅读(78) 评论(0) 推荐(0) 编辑
摘要: char * convertToBase7(int num){ if (num==0) return "0"; char* s = (char*)calloc(1001,sizeof(char)); int pst=1000, flag=(num<0)?1 :0; num = abs(num); c 阅读全文
posted @ 2020-12-01 12:10 温暖了寂寞 阅读(83) 评论(0) 推荐(0) 编辑
摘要: int calPoints(char ** ops, int opsSize){ int arr[1000]={0}, i, pst=0, temp, sum=0; for(i=0; i<opsSize; i++){ if(isdigit(ops[i][0]) || ops[i][0] == '-' 阅读全文
posted @ 2020-12-01 11:36 温暖了寂寞 阅读(86) 评论(0) 推荐(0) 编辑
摘要: int maxProfit(int* prices, int pricesSize){ int sum=0, i, max=0; for(i=1; i<pricesSize; i++){ sum += prices[i]-prices[i-1]; if(sum<0) sum=0; if(sum>ma 阅读全文
posted @ 2020-12-01 11:00 温暖了寂寞 阅读(63) 评论(0) 推荐(0) 编辑
摘要: int maxProfit(int* prices, int pricesSize){ int ans = 0; for (int i = 1; i < pricesSize; ++i) { /* 当天价格大于前一天价格,前一天买入,当天卖出,利润累加 */ ans += fmax(0, price 阅读全文
posted @ 2020-12-01 09:45 温暖了寂寞 阅读(55) 评论(0) 推荐(0) 编辑