[LeetCode]72. Edit Distance

[LeetCode]72. Edit Distance

原题链接Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.虽然题目出现的地方比较多了,看到英文的描述有清晰了几分,把 word1 转换成 word2 的最少操作次数,所有的操作都是针对word1 的确定这个才比较好理解下面每种情况对...

编程 2020-01-08 PM 7次 0条
[LeetCode] 70. Climbing Stairs

[LeetCode] 70. Climbing Stairs

题目描述原题链接You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?【中文】你正在爬 n 级楼梯, 每次可以选择走一步...

编程 2020-01-07 PM 12次 0条
[LeetCode] 63. Unique Paths II

[LeetCode] 63. Unique Paths II

这题是62 的变种, 输入一个 m 行 n 列的二维数组,其中为1 的表示遇到障碍,不能通行,求机器人从左上角走到右下角有几种走法解题思路还是动态规划,并没太大变化,唯一不同的是 遇到任何1 的点 dpi = 0 下面的代码有个小问题,paths 里存的是 long , 主要是 leetcode 存 int 会报错,其实并没错。class Solution { public: int...

编程 2020-01-07 PM 16次 0条
[LeetCode] 62. Unique Paths

[LeetCode] 62. Unique Paths

题目一机器人在 m 列 n 行的网格的左上角,机器人每次只能向下或向右移动一个格子,移动到右下角的格子有多少条路径上图是一个 7 列 3 行的示例图注意: m 和 n 小于 100例子1:Input: m = 3, n = 2 Output: 3 Explanation: From the top-left corner, there are a total of 3 ways to rea...

编程 2020-01-06 PM 10次 0条
[LeetCode] 53 Maximum contiguous subarray

[LeetCode] 53 Maximum contiguous subarray

题目Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.给定一个整数数组,寻找和最大的连续子数组的和。例子:Input: [-2,1,-3,4,-1,2,1,-5,4],Ou...

编程 2020-01-05 AM 13次 0条