摘要:
int Mycmp(const void* a, const void* b) { return *(int*)a - *(int*)b; } int findUnsortedSubarray(int* nums, int numsSize){ int* arr = (int*)calloc(num 阅读全文
摘要:
char * restoreString(char * s, int* indices, int indicesSize){ char* RetStr = (char*)calloc(indicesSize+1, sizeof(char)); for (int i = 0; i < indicesS 阅读全文
摘要:
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 阅读全文
摘要:
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[ 阅读全文
摘要:
#include "stdafx.h" #include <stdlib.h> #include <time.h> int main() { int a; srand((unsigned)time(NULL)); //设置随机种子后 随机数会形成固定的序列 a = rand(); printf("% 阅读全文
摘要:
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 阅读全文
摘要:
int* sortArrayByParityII(int* A, int ASize, int* returnSize){ int* arr = (int*)calloc(ASize,sizeof(int)); int evenindex = 0; int oddindex = 1; for (in 阅读全文
摘要:
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 阅读全文
摘要:
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< 阅读全文
摘要:
int findString(char** words, int wordsSize, char* s){ for (int i=0; i<wordsSize; i++)if (!strcmp(words[i],s)) return i; return -1; } 阅读全文
摘要:
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 阅读全文
摘要:
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; 阅读全文