摘要: class Solution { public: vector<vector<int>> levelOrder(TreeNode* root) { vector <vector <int>> ret; if (!root) { return ret; } queue <TreeNode*> q; q 阅读全文
posted @ 2020-12-15 19:54 温暖了寂寞 阅读(95) 评论(0) 推荐(0) 编辑
摘要: bool recursion(struct TreeNode* root,long lower,long upper){ if(!root) return true; if(root->val <= lower || root->val >= upper) return false; return 阅读全文
posted @ 2020-12-15 17:20 温暖了寂寞 阅读(99) 评论(0) 推荐(0) 编辑
摘要: struct TreeNode** buildTree(int start, int end, int* returnSize) { if (start > end) { (*returnSize) = 1; struct TreeNode** ret = malloc(sizeof(struct 阅读全文
posted @ 2020-12-15 12:18 温暖了寂寞 阅读(51) 评论(0) 推荐(0) 编辑
摘要: int numTrees(int n){ int hash[50]={0} ,i, j; hash[0]=1; for(i=1; i<=n; i++) for(j=1; j<=i; j++) hash[i] += hash[j-1]*hash[i-j]; return hash[n]; } 阅读全文
posted @ 2020-12-15 12:16 温暖了寂寞 阅读(56) 评论(0) 推荐(0) 编辑