摘要:
int lengthOfLIS(int* nums, int numsSize){ int len = 1, n = numsSize; if (n == 0) { return 0; } int* d= (int*)calloc(n+1,sizeof(int)); d[len] = nums[0] 阅读全文
摘要:
#define MAX(a,b) ((a) > (b) ? (a) :(b)) #define MIN(a,b) ((a) < (b) ? (a) :(b)) int computeArea(int A, int B, int C, int D, int E, int F, int G, int H 阅读全文
摘要:
int countNodes(struct TreeNode* root){ return (root)?countNodes(root->left)+countNodes(root->right)+1 :0; } 阅读全文
摘要:
int* majorityElement(int* nums, int numsSize, int* returnSize){ int* res =(int*)calloc(2,sizeof(int)); *returnSize=0; if (nums == NULL || numsSize == 阅读全文
摘要:
inline int partition(int* a, int l, int r) { int x = a[r], i = l - 1; for (int j = l; j < r; ++j) { if (a[j] <= x) { int t = a[++i]; a[i] = a[j], a[j] 阅读全文
摘要:
#define min(a,b) ((a)<(b))?(a):(b) int maximalSquare(char** matrix, int matrixSize, int* matrixColSize){ int* row = (int*)calloc(*matrixColSize, sizeo 阅读全文
摘要:
void recursion(int k,int n,int* returnSize,int* ColSize,int start,int cnt,int sum,int* temp,int** arr){ if(cnt==k){ if(sum==n){ arr[(*returnSize)]=(in 阅读全文
摘要:
#define max(a,b) ((a)>(b))?(a):(b); int rob(int* nums, int numsSize){ if(numsSize==1) return *nums; int dp[2][101]={0}; dp[0][0]=nums[0]; dp[0][1]=num 阅读全文
摘要:
int* findOrder(int numCourses, int** prerequisites, int prerequisitesSize, int* prerequisitesColSize, int* returnSize){ int** edges = (int**)calloc(nu 阅读全文
摘要:
int** edges; int* edgeColSize; int* visited; bool valid; void dfs(int u) { visited[u] = 1; for (int i = 0; i < edgeColSize[u]; ++i) { if (visited[edge 阅读全文