上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页
摘要: 原题思路:用到dp的思想,到row,col点路径数量 :path[row][col]=path[row][col-1]+path[row-1][col];遍历row*col,如果map[row][col]为1,则将其置为0;如果非1,则进行上述公式。最后返回... 阅读全文
posted @ 2018-10-16 22:38 Ruohua3kou 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 不规则区域的填充算法 利用Dfs实现简单递归填充。 核心代码: 完整代码: 阅读全文
posted @ 2018-10-16 19:51 Ruohua3kou 阅读(880) 评论(0) 推荐(0) 编辑
摘要: 原题简单动态规划重点是:grid[i][j] += min(grid[i][j - 1], grid[i - 1][j]);class Solution { public: int minPathSum(vector> &grid) { for (i... 阅读全文
posted @ 2018-10-16 11:40 Ruohua3kou 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 原题前后两遍遍历class Solution{public: int candy(vector &ratings) { vector res; int len = ratings.size(); for (int i = 0; i 0... 阅读全文
posted @ 2018-10-16 11:01 Ruohua3kou 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 原题题意:过一个循环的加油站,每个加油站可以加一定数量的油,走到下一个加油站需要消耗一定数量的油,判断能否走一圈。思路:一开始思路就是遍历一圈,最直接的思路。class Solution{ public: int canCompleteCircuit... 阅读全文
posted @ 2018-10-15 00:27 Ruohua3kou 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std;struct Pos{ int x; int y;};struct Edge{ int x1, x2; int y1, y2; ... 阅读全文
posted @ 2018-10-14 23:19 Ruohua3kou 阅读(936) 评论(0) 推荐(0) 编辑
摘要: 原题题意:是Jump Game的衍生题(题解),题意求跳到最后一格所需最少步数,(默认所测数据永远可以跳到最后一格)。思路:利用贪心,遍历数组,记录在每一步可跳跃到的最大区域。1.当前步数 超过已覆盖范围,则表示需要进行跳跃,同时更新已覆盖区域,可覆盖区域。... 阅读全文
posted @ 2018-10-13 10:54 Ruohua3kou 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 原题题目意思即 每一格代表你当前最多能再往后跳几次,从第一格开始,如果能跳到最后一格返回true,反之为false。思路:用一个下标记录当前最多能跳到哪一格,遍历一遍 ——> 如果当前格子不在可以跳到的范围内,则跳出遍历 ——> 如果最多能跳到格子长度大于... 阅读全文
posted @ 2018-10-12 15:34 Ruohua3kou 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 原题判断子序列/** * @param {string} s * @param {string} t * @return {boolean} */var isSubsequence = function(s, t) { var sl = s.length;... 阅读全文
posted @ 2018-10-11 14:37 Ruohua3kou 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 原题别人的思路 非常简洁function ListNode(val) { this.val = val; this.next = null;}/** * @param {ListNode} head * @return {ListNode} */var ... 阅读全文
posted @ 2018-10-10 14:39 Ruohua3kou 阅读(120) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页