diff --git a/notes/Leetcode 题解.md b/notes/Leetcode 题解.md index 180f4573..0cc169dc 100644 --- a/notes/Leetcode 题解.md +++ b/notes/Leetcode 题解.md @@ -1768,7 +1768,7 @@ public int minPathSum(int[][] grid) { ¶¨ÒåÒ»¸öÊý×é dp ´æ´¢ÉÏÂ¥Ìݵķ½·¨Êý£¨ÎªÁË·½±ãÌÖÂÛ£¬Êý×éϱê´Ó 1 ¿ªÊ¼£©£¬dp[i] ±íʾ×ßµ½µÚ i ¸öÂ¥Ìݵķ½·¨ÊýÄ¿¡£µÚ i ¸öÂ¥ÌÝ¿ÉÒÔ´ÓµÚ i-1 ºÍ i-2 ¸öÂ¥ÌÝÔÙ×ßÒ»²½µ½´ï£¬×ßµ½µÚ i ¸öÂ¥Ìݵķ½·¨ÊýΪ×ßµ½µÚ i-1 ºÍµÚ i-2 ¸öÂ¥Ìݵķ½·¨ÊýÖ®ºÍ¡£ -**dp[i] = dp[i-1] + dp[i-2]** +![](http://latex.codecogs.com/gif.latex?\\\\dp[i]=dp[i-1]+dp[i-2]) dp[N] ¼´ÎªËùÇó¡£ @@ -1797,7 +1797,7 @@ public int climbStairs(int n) { µÚ i Äê³ÉÊìµÄÅ£µÄÊýÁ¿Îª£º -**dp[i] = dp[i-1] + dp[i-3]** +![](http://latex.codecogs.com/gif.latex?\\\\dp[i]=dp[i-1]+dp[i-3]) **Ç¿µÁÇÀ½Ù** @@ -1807,7 +1807,7 @@ public int climbStairs(int n) { ¶¨Òå dp Êý×éÓÃÀ´´æ´¢×î´óµÄÇÀ½ÙÁ¿£¬ÆäÖÐ dp[i] ±íʾÇÀµ½µÚ i ¸öס»§Ê±µÄ×î´óÇÀ½ÙÁ¿¡£ÓÉÓÚ²»ÄÜÇÀ½ÙÁÚ½üס»§£¬Òò´ËÈç¹ûÇÀ½ÙÁËµÚ i ¸öס»§ÄÇôֻÄÜÇÀ½Ù i - 2 ºÍ i - 3 µÄס»§£¬ËùÒÔ -**dp[i] = max(dp[i - 2], dp[i - 3]) + nums[i]** +![](http://latex.codecogs.com/gif.latex?\\\\dp[i]=max(dp[i-2],dp[i-3])+nums[i]) O(n) ¿Õ¼ä¸´ÔÓ¶ÈʵÏÖ·½·¨£º @@ -1999,13 +1999,7 @@ public int wiggleMaxLength(int[] nums) { ×ÛÉÏ£¬×¹«¹²×ÓϵÁеÄ״̬תÒÆ·½³ÌΪ£º -![](http://latex.codecogs.com/gif.latex?\\\\ -dp[i][j]=\left\{ -\begin{array}{rcl} -dp[i-1][j-1]&&{S1_i==S2_j}\\ -max(dp[i-1][j],dp[i][j-1])&&{S1_i<>S2_j} -\end{array}\right. -) +![](http://latex.codecogs.com/gif.latex?\\\\dp[i][j]=\left\{\begin{array}{rcl}dp[i-1][j-1]&&{S1_i==S2_j}\\max(dp[i-1][j],dp[i][j-1])&&{S1_i<>S2_j}\end{array}\right.) ¶ÔÓÚ³¤¶ÈΪ N µÄÐòÁÐ S1 ºÍ ³¤¶ÈΪ M µÄÐòÁÐ S2£¬dp[N][M] ¾ÍÊÇÐòÁÐ S1 ºÍÐòÁÐ S2 µÄ×¹«¹²×ÓÐòÁг¤¶È¡£