7.21 贪心 动态开头
This commit is contained in:
parent
dbd0be69e8
commit
c323d88ebc
@ -13,6 +13,7 @@ package dynamic_programming;
|
||||
|
||||
* 链接:https://leetcode.cn/problems/climbing-stairs/
|
||||
*/
|
||||
//二刷会做
|
||||
public class ClimbStairs {
|
||||
public int climbStairs(int n) {
|
||||
if(n <= 2) return n;
|
||||
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||
|
||||
* 链接:https://leetcode.cn/problems/pascals-triangle/
|
||||
*/
|
||||
//二刷会做
|
||||
public class Generate {
|
||||
public List<List<Integer>> generate(int numRows) {
|
||||
List<List<Integer>>res=new ArrayList<>();
|
||||
|
@ -14,6 +14,7 @@ import java.util.Arrays;
|
||||
|
||||
* 链接:https://leetcode.cn/problems/jump-game/
|
||||
*/
|
||||
//二刷会做
|
||||
public class CanJump {
|
||||
//接近超时!记忆化搜索,记录每一个状态(这里是索引 i)是否能成功跳到最后。
|
||||
public boolean canJump1(int[] nums) {
|
||||
|
@ -18,6 +18,7 @@ package greedy;
|
||||
*/
|
||||
|
||||
//不会 https://programmercarl.com/0045.%E8%B7%B3%E8%B7%83%E6%B8%B8%E6%88%8FII.html#%E6%80%9D%E8%B7%AF
|
||||
//二刷不会
|
||||
public class Jump {
|
||||
//要从覆盖范围出发,不管怎么跳,覆盖范围内一定是可以跳到的,以最小的步数增加覆盖范围,覆盖范围一旦覆盖了终点,得到的就是最少步数!
|
||||
public int jump(int[] nums) {
|
||||
|
@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
* 链接:https://leetcode.cn/problems/partition-labels/
|
||||
*/
|
||||
//二刷会做
|
||||
public class PartitionLabels {
|
||||
/**
|
||||
* 可以通过,但是时间复杂度高!
|
||||
|
Loading…
x
Reference in New Issue
Block a user