摘要:
1.前序中序确定class Solution {public: TreeNode *buildTree(vector &preorder, vector &inorder) { if(preorder.size()==0||inorder.size()==0||preorder.size()!=inorder.size())return NULL; TreeNode *root=NULL; build(root,preorder,inorder,0,preorder.size()-1,0,inorder.size()-1); ... 阅读全文
摘要:
Combination Sum回溯法应用数组不含重复元素,结果可含重复元素。回溯法。自己写的代码:class Solution {public:vector<vector<int>>v;vector<int>v1;int sum; vector<vector<int> > combinationSum(vector<int> &candidates, int target) { sort(candidates.begin(),candidates.end()); v.clear(); sum=0; backtrac 阅读全文