摘要: 62: 来源: 重点: 类似这种只问有多少种方案,而不问具体方案是什么时,常用动态规划。 动态规划,数组dp[m][n]为状态数组,表示到达(m-1,,n-1)点的路径数量 class Solution { public int uniquePaths(int m, int n) { int[][] 阅读全文
posted @ 2021-11-15 21:38 一半知半 阅读(15) 评论(0) 推荐(0)
摘要: 来源: 1 class Solution { 2 public boolean canJump(int[] nums) { 3 boolean flag = false; 4 int n = nums.length; 5 int pos = 0;//记录最远可到达的位置 6 int i = 0;// 阅读全文
posted @ 2021-11-15 21:18 一半知半 阅读(21) 评论(0) 推荐(0)
摘要: 方法1:暴力解法 难点: 递归的生成所有的括号(递归算法) generateAll(current, 0, combinations) current:当前字符数组, pos:当前写入括号的位置, combinations:当前所有合法的长度为2n的集合 判断括号是否合法 遍历字符数组,遇到'(', 阅读全文
posted @ 2021-11-15 19:22 一半知半 阅读(161) 评论(0) 推荐(0)