常见的DP题目和状态转移方程
爬楼梯
不同路径
例如F点,右子树高度1 - 左子树高度2 = -1
1,目标函数单调性(单调递增或者递减)——在有序的里面查找
2,存在上下界(bounded)
3,能够通过索引访问(index accessible)
(一定要写的非常熟练)
1 | left,right := 0,len(array) - 1 |
The count-and-say sequence is a sequence of digit strings defined by the recursive formula:
To determine how you “say” a digit string, split it into the minimal number of groups so that each group is a contiguous section all of the same character. Then for each group, say the number of characters, then say the character. To convert the saying into a digit string, replace the counts with a number and concatenate every saying.