-
学习笔记
Longest common sequence(最长子序列)
if(s1[i-1]==s2[j-1])
dp[i][j]=dp[i-1][j-1]+1
else
dp[i][j]=max(dp[i-1][j],dp[i][j-1])
Longest common substring(最长子串)
if(s1[i-1]==s2[j-1])
dp[i…
-
-
不同路径 II
obstacleGrid[i][j] = obstacleGrid[i - 1][j] + obstacleGrid[i][j - 1]
Longest common sequence(最长子序列)
if(s1[i-1]==s2[j-1])
dp[i][j]=dp[i-1][j-1]+1
else
dp[i][j]=max(dp[i-1][j],dp[i][j-1]…
-
第 8 周 第 19 课
高级动态规划
最近重复性:
拆解的过于小的话,程序会比较繁琐
最大公约数
动态规划 Dynamic Programming
将复杂问题分解成简单的子问题
分治+最优子结构
顺推形式:动态递推
与分治对比
动态规划和递归或者分治没有根本上的区别(关键看有无最优子结构)
========================================…
-
-
# Proposal
## Problem statement
I want to:
- Split a string at several possible delimiters, where each delimiter may consist of zero or more characters
- Find the first/last occurrence of an…
-
It looks like the duplicate code report is shown always for code on two files. If we have, for example, the same method on 4 different files, we won't get a report saying that the block of code is fou…
-
Create Readme per algo with the following components:
- [x] Algo name (as heading)
- [x] A small description about algo
- [x] Time Complexity (Worst, Average, Best case)
- [x] Space Complexity (Wo…
-
## 不同路径2的状态转移方程
```
if ob[i][j] == 1:
dp[i][j] = 0
else:
dp[i][j] = dp[i-1][j] + dp[i][j-1]
```
## Rabin-Karp 代码示例
```
public final static int D = 256;
public final static int Q …
-
# 高级动态规划
## 复杂来源
1. 状态拥有更多维度(二维、三维或者更多,必要的时候需要压缩)
2. 状态方程更加复杂
## 不同路径2状态转移方程
dp[i][j] = (obstacleGrid[i - 1][j] ? 0 : dp[i - 1][j]) + (obstacleGrid[i][j - 1] ? 0 : dp[i][j - 1])
# 字符…
cmnoe updated
4 years ago