摘要: int Mycmp(const void* a, const void* b) { return *(int*)a - *(int*)b; } int findUnsortedSubarray(int* nums, int numsSize){ int* arr = (int*)calloc(num 阅读全文
posted @ 2020-09-05 20:47 温暖了寂寞 阅读(124) 评论(0) 推荐(0) 编辑
摘要: char * restoreString(char * s, int* indices, int indicesSize){ char* RetStr = (char*)calloc(indicesSize+1, sizeof(char)); for (int i = 0; i < indicesS 阅读全文
posted @ 2020-09-05 19:58 温暖了寂寞 阅读(309) 评论(0) 推荐(0) 编辑
摘要: int* shuffle(int* nums, int numsSize, int n, int* returnSize){ int* arr = (int*)calloc(numsSize, sizeof(int)); int pst = 0; for (int i = 0; i < numsSi 阅读全文
posted @ 2020-09-05 19:42 温暖了寂寞 阅读(164) 评论(0) 推荐(0) 编辑
摘要: int smallestRangeI(int* A, int ASize, int K){ int min = A[0]; int max = A[0]; for (int i = 0; i < ASize; i++) { if (A[i] < min)min = A[i]; else if (A[ 阅读全文
posted @ 2020-09-05 19:10 温暖了寂寞 阅读(200) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h" #include <stdlib.h> #include <time.h> int main() { int a; srand((unsigned)time(NULL)); //设置随机种子后 随机数会形成固定的序列 a = rand(); printf("% 阅读全文
posted @ 2020-09-05 18:52 温暖了寂寞 阅读(1434) 评论(0) 推荐(0) 编辑
摘要: int Mycmp(const void* a,const void* b) { return *(int*)a % 2 - *(int*)b % 2; } int* sortArrayByParity(int* A, int ASize, int* returnSize){ qsort(A,ASi 阅读全文
posted @ 2020-09-05 15:14 温暖了寂寞 阅读(116) 评论(0) 推荐(0) 编辑
摘要: int* sortArrayByParityII(int* A, int ASize, int* returnSize){ int* arr = (int*)calloc(ASize,sizeof(int)); int evenindex = 0; int oddindex = 1; for (in 阅读全文
posted @ 2020-09-05 15:07 温暖了寂寞 阅读(105) 评论(0) 推荐(0) 编辑
摘要: int Fun(int x){ int res=0; while (x) res+=x&1,x>>=1; return res; } int Mycmp(const void* a,const void* b){ return (Fun(*(int*)a) - Fun(*(int*)b))? Fun 阅读全文
posted @ 2020-09-05 14:34 温暖了寂寞 阅读(157) 评论(0) 推荐(0) 编辑
摘要: int Mycmp(const void* a,const void* b){ return *(int*)a - *(int*)b; } void merge(int* A, int ASize, int m, int* B, int BSize, int n){ for (int i=m; i< 阅读全文
posted @ 2020-09-05 13:50 温暖了寂寞 阅读(119) 评论(0) 推荐(0) 编辑
摘要: int findString(char** words, int wordsSize, char* s){ for (int i=0; i<wordsSize; i++)if (!strcmp(words[i],s)) return i; return -1; } 阅读全文
posted @ 2020-09-05 13:15 温暖了寂寞 阅读(136) 评论(0) 推荐(0) 编辑
摘要: int balancedStringSplit(char * s){ int count=0,num = 0; for (int i=0; i<=strlen(s); i++) { (s[i] == 'R') ? count++:count--; if (!count) num++; } retur 阅读全文
posted @ 2020-09-05 12:07 温暖了寂寞 阅读(88) 评论(0) 推荐(0) 编辑
摘要: int Mycmp(const void* a,const void* b) { return *(int*)a - *(int*)b; } int* sortedSquares(int* A, int ASize, int* returnSize){ for (int i=0; i<ASize; 阅读全文
posted @ 2020-09-05 10:40 温暖了寂寞 阅读(117) 评论(0) 推荐(0) 编辑