diff --git a/AlgorithmHomework6.md b/AlgorithmHomework6.md index 56db504..69960ca 100644 --- a/AlgorithmHomework6.md +++ b/AlgorithmHomework6.md @@ -17,9 +17,9 @@ Leetcode: 5, 64, 120 - **算法思路:** - 使用动态规划的思想; - - 状态转移方程如下: - $P(i, j) = \left\{ \begin{array}{ll}True & \textrm{if $P(i + 1, j - 1) $ and $ S_i == S_j $}\\False & \textrm{其它}\\\end{array} \right.$ + + $P(i, j) = \begin{cases}True &\text{if } P(i + 1, j - 1)==True , S_i == S_j \\False &\text{if 其它 } \end{cases}$ - 首先判断长度为1的子串,再判断长度为2的子串,再判断长度为3的子串,以此类推。 @@ -55,8 +55,8 @@ Leetcode: 5, 64, 120 - 采用动态规划的思想,自右下角向左上脚遍历。 - 首先将最下面一排的路径开销自右往左以此叠加,把最右边一排的路径开销自下往上以此叠加,接着其它情况使用与下述状态转换方程: - - $P(i, j) = \left\{ \begin{array}{ll}P(i, j) + P(i + 1, j) & \textrm{if $ P(i, j + 1) >= P(j + 1) $}\\P(i, j) + P(i, j + 1) & \textrm{if $ P(i, j + 1) < P(j + 1) $}\\\end{array} \right.$ + + $P(i, j) = \begin{cases}P(i, j) + P(i + 1, j) &\text{if } P(i, j + 1) >= P(j + 1) \\P(i, j) + P(i, j + 1) &\text{if }P(i, j + 1) < P(j + 1) \end{cases}$ - **Leetcode提交结果:** @@ -87,8 +87,8 @@ Leetcode: 5, 64, 120 - 用动态规划的思想,自底向上一次计算到当前访问节点到叶子节点的最短路径; - 状态转移方程如下: - - $P(row, index) = \left\{ \begin{array}{ll}P(row, index) & \textrm{if $ row == len(triangle) - 1 $}\\P(row, index) + min(P(row + 1, index), P(row + 1, index + 1))& \textrm{if $ P(i, j + 1) < P(j + 1) $}\\\end{array} \right.$ + + $P(row, index) = \begin{cases}P(row, index) &\text{if } row == len(triangle) - 1 \\P(row, index) + min(P(row + 1, index), P(row + 1, index + 1)) &\text{if }row < len(triangle) - 1 \end{cases}$ - **Leetcode提交结果:**