摘要:
此题dfs用的出神入化 class Solution { public: vector<vector<int>> res; vector<int> temp; vector<vector<int>> subsets(vector<int>& nums) { dfs(nums,0); return r 阅读全文
posted @ 2021-07-17 16:22
三一一一317
阅读(29)
评论(0)
推荐(0)
摘要:
求解方法 知道了编辑距离的定义,那么如何求最小编辑距离呢?这里用到了动态规划的思想。 用例子来说明,假如我们要求解 jary和jerry的最小编辑距离,那么首先要创建如下矩阵: Φ j a r y Φ 0 1 2 3 4 j 1 e 2 r 3 r 4 y 5 这个矩阵什么意思呢?第一行是字符串ja 阅读全文
posted @ 2021-07-17 15:01
三一一一317
阅读(121)
评论(0)
推荐(0)
摘要:
和62题不同路径一样,使用dfs方法同样超时。 class Solution { public: vector<int> res; int minPathSum(vector<vector<int>>& grid) { int m = grid.size(); int n = grid[0].siz 阅读全文
posted @ 2021-07-17 14:17
三一一一317
阅读(28)
评论(0)
推荐(0)
摘要:
第一种方法 DFS 果然超时 class Solution { public: int count = 0; int uniquePaths(int m, int n) { vector<vector<bool>> visited(m, vector<bool>(n,false)); path(vi 阅读全文
posted @ 2021-07-17 13:45
三一一一317
阅读(28)
评论(0)
推荐(0)
摘要:
算法解析: class Solution { public: vector<vector<int>> merge(vector<vector<int>>& intervals) { // 此题最关键的就是排序,如果不排序很难处理 sort(intervals.begin(), intervals.e 阅读全文
posted @ 2021-07-17 13:10
三一一一317
阅读(25)
评论(0)
推荐(0)
摘要:
第一种方式超时 class Solution { public: bool canJump(vector<int>& nums) { if(jump(nums,0)) return true; return false; } bool jump(vector<int> nums,int index) 阅读全文
posted @ 2021-07-17 11:57
三一一一317
阅读(39)
评论(0)
推荐(0)