stl
qw___
库里MVP
展开
-
二叉树的建立(后序+中序)
106. Construct Binary Tree from Inorder and Postorder Traversal/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeN原创 2017-04-10 13:57:59 · 415 阅读 · 1 评论 -
二叉树的建立(先序+中序)
105. Construct Binary Tree from Preorder and Inorder Traversal/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNo原创 2017-04-10 14:02:44 · 294 阅读 · 1 评论 -
数字序列全组合(递归)
78. Subsetsclass Solution {public: vector<vector<int>> subsets(vector<int>& nums) { vector<vector<int> > v; vector<int> temp; int length = nums.size(); for(int原创 2017-04-13 14:09:35 · 1082 阅读 · 1 评论 -
点到点路径和问题(动态规划)
62. Unique Paths 求解Start到Finish路径的总和,只允许从起点位置向下或者向右移动。 设v为路径统计矩阵,v[i][j]为经过i,j位置的路径总数。 状态转移方程:v[i][j] = v[i-1][j] + v[i][j-1];class Solution {public: int uniquePaths(int m, int n) { v原创 2017-04-18 13:09:53 · 1183 阅读 · 1 评论 -
存在障碍的点到点路径和问题(动态规划)
63. Unique Paths II 原地解法:class Solution {public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int m = obstacleGrid.size(); int n = obstacleGrid[0].size()原创 2017-04-18 14:53:08 · 938 阅读 · 1 评论