摘要: 给定一个字符串,表示一串文件路径,其中 '.','/' 可以跳过,'..' 表示返回上一层路径,输出最终的路径。 Input: "/a/./b/../../c/"Output: "/c" Input: "/home//foo/"Output: "/home/foo"Explanation: In t 阅读全文
posted @ 2020-05-31 19:53 星海寻梦233 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 给定一个矩阵,矩阵中的元素表示成本,求,从矩阵左上角到右下角最小的成本路线,每一次只能向右或者向下走。 Input:[ [1,3,1], [1,5,1], [4,2,1]]Output: 7Explanation: Because the path 1→3→1→1→1 minimizes the s 阅读全文
posted @ 2020-05-31 16:59 星海寻梦233 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 给定一个矩阵,矩阵元素由0/1组成,0表示可以通过,1表示有障碍,不能通过,且每次只能向右走或者向下走,求从矩阵左上角走到矩阵右下角的路线条数。 Input:[ [0,0,0], [0,1,0], [0,0,0]]Output: 2Explanation:There is one obstacle 阅读全文
posted @ 2020-05-31 16:31 星海寻梦233 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 给定2个正整数 m, n ,表示长和宽,求从左上角到右下角的路线条数,每次只能向右走或者向下走。 Input: m = 7, n = 3Output: 28 思路:一、利用递归思想,但是提交OJ,显示运行超时,不能AC。 class Solution { public: int uniquePath 阅读全文
posted @ 2020-05-31 15:56 星海寻梦233 阅读(111) 评论(0) 推荐(0) 编辑