From dd1578489c9ac783c3587f7521659b866bb8eb1b Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Thu, 22 Feb 2018 17:10:27 +0800 Subject: [PATCH] auto commit --- notes/Leetcode 题解.md | 32 +++++------------- pics/1dc481cc-99f6-4fa8-8f68-fbd563995bf5.png | Bin 0 -> 9216 bytes 2 files changed, 9 insertions(+), 23 deletions(-) create mode 100644 pics/1dc481cc-99f6-4fa8-8f68-fbd563995bf5.png diff --git a/notes/Leetcode 题解.md b/notes/Leetcode 题解.md index 0cc169dc..89e32b92 100644 --- a/notes/Leetcode 题解.md +++ b/notes/Leetcode 题解.md @@ -1999,7 +1999,15 @@ 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. +) + +![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/1dc481cc-99f6-4fa8-8f68-fbd563995bf5.png) ¶ÔÓÚ³¤¶ÈΪ N µÄÐòÁÐ S1 ºÍ ³¤¶ÈΪ M µÄÐòÁÐ S2£¬dp[N][M] ¾ÍÊÇÐòÁÐ S1 ºÍÐòÁÐ S2 µÄ×¹«¹²×ÓÐòÁг¤¶È¡£ @@ -2064,7 +2072,6 @@ public int knapsack(int W, int N, int[] weights, int[] values) { ÒòΪ dp[j-w] ±íʾ dp[i-1][j-w]£¬Òò´Ë²»ÄÜÏÈÇó dp[i][j-w] ·ÀÖ¹½« dp[i-1][j-w] ¸²¸Ç¡£Ò²¾ÍÊÇ˵ҪÏȼÆËã dp[i][j] ÔÙ¼ÆËã dp[i][j-w]£¬ÔÚ³ÌÐòʵÏÖʱÐèÒª°´µ¹ÐòÀ´Ñ­»·Çó½â¡£ - **ÎÞ·¨Ê¹ÓÃÌ°ÐÄËã·¨µÄ½âÊÍ** 0-1 ±³°üÎÊÌâÎÞ·¨Ê¹ÓÃÌ°ÐÄËã·¨À´Çó½â£¬Ò²¾ÍÊÇ˵²»ÄÜ°´ÕÕÏÈÌí¼ÓÐÔ¼Û±È×î¸ßµÄÎïÆ·À´´ïµ½×îÓÅ£¬ÕâÊÇÒòΪÕâÖÖ·½Ê½¿ÉÄÜÔì³É±³°ü¿Õ¼äµÄÀË·Ñ£¬´Ó¶øÎÞ·¨´ïµ½×îÓÅ¡£¿¼ÂÇÏÂÃæµÄÎïÆ·ºÍÒ»¸öÈÝÁ¿Îª 5 µÄ±³°ü£¬Èç¹ûÏÈÌí¼ÓÎïÆ· 0 ÔÙÌí¼ÓÎïÆ· 1£¬ÄÇôֻÄÜ´æ·ÅµÄ¼ÛֵΪ 16£¬ÀË·ÑÁË´óСΪ 2 µÄ¿Õ¼ä¡£×îÓŵķ½Ê½ÊÇ´æ·ÅÎïÆ· 1 ºÍÎïÆ· 2£¬¼ÛֵΪ 22. @@ -2448,9 +2455,6 @@ public int minDistance(String word1, String word2) { [Leetcode : 72. Edit Distance (Hard)](https://leetcode.com/problems/edit-distance/description/) -**ÐÞ¸ÄÒ»¸ö×Ö·û´®Ê¹Ëü³ÉΪ»ØÎÄ×Ö·û´®**// TODO - -[³ÌÐòÔ±´úÂëÃæÊÔÖ¸ÄÏ-×Ö·û´®](#) ### ÆäËüÎÊÌâ @@ -2851,12 +2855,6 @@ public int majorityElement(int[] nums) { } ``` -**Êý×éÖгöÏÖ´ÎÊý¶àÓÚ n / k µÄÔªËØ** - -[³ÌÐòÔ±´úÂëÃæÊÔÖ¸ÄÏ P343](#) - -Ñ¡ k - 1 ¸öºòÑ¡ - ### ÆäËü **ƽ·½Êý** @@ -3428,14 +3426,6 @@ s1 ## Êý×éÓë¾ØÕó -**¾ØÕóÐýת** // TODO - -[³ÌÐòÔ±ÃæÊÔ½ðµä P114](#) - -**Ö®×ÖÐÍ´òÓ¡** //TODO - -[³ÌÐòÔ±´úÂëÃæÊÔÖ¸ÄÏ P335](#) - **°ÑÊý×éÖÐµÄ 0 ÒƵ½Ä©Î²** [Leetcode : 283. Move Zeroes (Easy)](https://leetcode.com/problems/move-zeroes/description/) @@ -4919,10 +4909,6 @@ public int getSum(int a, int b) { } ``` -**ʵÏÖÕûÊý³Ë·¨** - -[³ÌÐòÔ±´úÂëÃæÊÔÖ¸ÄÏ P319](#) - **×Ö·û´®Êý×é×î´ó³Ë»ý** [Leetcode : 318. Maximum Product of Word Lengths (Medium)](https://leetcode.com/problems/maximum-product-of-word-lengths/description/) diff --git a/pics/1dc481cc-99f6-4fa8-8f68-fbd563995bf5.png b/pics/1dc481cc-99f6-4fa8-8f68-fbd563995bf5.png new file mode 100644 index 0000000000000000000000000000000000000000..4723269fa2f4f1ea1cf4c54aea84c920459776ff GIT binary patch literal 9216 zcmeHt=RaIu^sWq|M4LhM-bIMc5Jv9|L!w4vqW4~cM2Qk+5QAVa`VhTE3ld`V=sm%Z z=#dbjg**A)`?-I?eerv7U(D=tKIeSae)isLuf3jUokXay4mBk!B@q!3wVtk~84(cx zOSpC*ze)HU+=9<~Hm|jv4G4;?26WySMya^`ZfALHQLv%09nS%5M1o#-x zLwKMM!I0d$LEd_Ot{rTkqhqn})LuS%HCrhw?O8dD1~+$9wr|$c!;>ZZnc+^cq?P~L z%WI@te!-<{qL7v{*QlYD(3p?;$UO5;JM1#c6mY2+R6S>`Lj%l zv$OqoD?c{l4?L27Uf{T%FYj+2)plQjzchMWT^@bDI4d&t??Oo8dI2-+q~K_-$kQjX z9C=o^FUWyo5!G4K%a+>U@_^K2UtP_i>b) zAlZ|1e3C@I@~=Mnx7%AIQX%UIdE-Z+-!k(4-v6`gUv6`urW5<-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