LeetCode 动态规划类题目以及要注意的点

所谓的动态规划 是一种手段 不像树或者图或者Math之类的题目一样 看到题目就知道这个是属于什么题目 应该用什么方式去做。
比如说 树的话 就是递归或者各种遍历
图的话就是BFS和DFS方式
而动态规划的题目 大多数是给一些数组(一维或者二维)然后让你去求一些最大最小值 或者是能否的问题。

什么情况下会考虑用这种方法?
当这道题不是一些典型的树 图 链表 Math 之类的题目 也不是一些需要用特殊数据结构比如并查集 PQ, Min Stack去做,而且用馋鬼的一些小技巧也挣不出来的时候 就要考虑这道题目是不是可以用DP/Backtracking/Greedy做

    1. Climbing Stairs
    1. Min Cost Climbing Stairs
    1. Best Time to Buy and Sell Stock
    1. Best Time to Buy and Sell Stock II
    1. Best Time to Buy and Sell Stock III
    1. Best Time to Buy and Sell Stock IV
    1. Best Time to Buy and Sell Stock with Cooldown
    1. House Robber
    1. House Robber II
    1. Range Sum Query - Immutable
    1. Decode Ways
    1. Unique Paths
    1. Unique Paths II
    1. Triangle
    1. Minimum Falling Path Sum
    1. Minimum Falling Path Sum II
    1. Perfect Squares
    1. Longest Palindromic Substring
    1. Video Stitching
    1. Longest String Chain
    1. Longest Common Subsequence
    1. Delete Operation for Two Strings
    1. Minimum ASCII Delete Sum for Two Strings
    1. Minimum Insertion Steps to Make a String Palindrome
    1. Maximal Square
    1. Jump Game V
    1. Number of Paths with Max Score
    1. Count Square Submatrices with All Ones
    1. Number of Ways to Stay in the Same Place After Some Steps
    1. Counting Bits
    1. Greatest Sum Divisible by Three
    1. Edit Distance
    1. Coin Change
    1. Coin Change 2
    1. Count Vowels Permutation
    1. Largest Divisible Subset
    1. Kth Ancestor of a Tree Node
    1. Find Two Non-overlapping Sub-arrays Each With Target Sum
    1. Target Sum
    1. Dungeon Game
    1. Unique Binary Search Trees
    1. Unique Binary Search Trees II
  1. 方法二:看了stefan的答案,更正一下自己的方法,lo==hi是没必要的,之前因为先考虑这个因素,没有删掉。deepcopy可以写成别的形式,在内循环生成root节点,而不是在外层生成一个再去拷贝。记忆化搜索也是没有必要的。用时比原来快了3倍。
    1. House Robber III
    1. Count Submatrices With All Ones
    1. Stone Game II
    1. Stone Game IV
    1. Number of Sub-arrays With Odd Sum
    1. Word Break
    1. Word Break II
    1. Restore The Array
    1. Get the Maximum Score
    1. Minimum Number of Days to Eat N Oranges
    1. Minimum Swaps To Make Sequences Increasing
    1. New 21 Game
    1. Soup Servings
    1. Minimum Cost For Tickets
    1. Matchsticks to Square
    1. Champagne Tower
    1. Predict the Winner
    1. Out of Boundary Paths
    1. Knight Probability in Chessboard
    1. Palindrome Partitioning II
    1. Partition Array for Maximum Sum
    1. Domino and Tromino Tiling
    1. Longest Increasing Path in a Matrix
    1. Shopping Offers
    1. Maximum Product Subarray
  2. LCP 20. 快速公交
    1. Stone Game
    1. Longest Increasing Subsequence
    1. Number of Longest Increasing Subsequence
  3. 面试题 17.08. 马戏团人塔
  4. 面试题 08.13. 堆箱子
    1. Maximum Non Negative Product in a Matrix
  5. 面试题 08.14. 布尔运算
  6. 面试题 17.13. 恢复空格
    1. Minimum One Bit Operations to Make Integers Zero
    1. Longest Arithmetic Subsequence
    1. 分割等和子集
    1. Longest Consecutive Sequence
    1. Matrix Block Sum
    1. Best Team With No Conflicts
    1. Binary Trees With Factors
    1. Delete and Earn
    1. Arithmetic Slices
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值