diff --git a/notes/Leetcode 题解.md b/notes/Leetcode 题解.md index 33cc705a..9e9a3186 100644 --- a/notes/Leetcode 题解.md +++ b/notes/Leetcode 题解.md @@ -230,9 +230,9 @@ public int findMinArrowShots(int[][] points) { [Leetcode : 122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/) -ÏÈÂòÈë¹ÉƱ£¬È»ºó³öÊÛ¹ÉÆ±£¬´Ó¶ø»ñµÃ²î¼Û´øÀ´µÄÊÕÒæ¡£ +ÌâÄ¿ÃèÊö£ºÒ»´Î½»Ò×°üº¬ÂòÈëºÍÂô³ö£¬¶à¸ö½»Ò×Ö®¼ä²»Äܽ»²æ½øÐС£ -¶ÔÓÚÒ»¸ö½»Ò× [a, b, c, d]£¬Èç¹ûÓÐ a <= b <= c <= d £¬ÄÇô×î´óÊÕÒæÎª d - a = (d - c) + (c - b) + (b - a) ¡£µ±·ÃÎʵ½Ò»¸ö prices[i] ÇÒ prices[i] - prices[i-1] £¬ÄÇô¾Í°Ñ prices[i] - prices[i-1] ¼Óµ½ÊÕÒæÖУ¬´Ó¶øÔÚ¾Ö²¿×îÓŵÄÇé¿öÏÂÒ²±£Ö¤È«¾Ö×îÓÅ¡£ +¶ÔÓÚ [a, b, c, d]£¬Èç¹ûÓÐ a <= b <= c <= d £¬ÄÇô×î´óÊÕÒæÎª d - a¡£¶ø d - a = (d - c) + (c - b) + (b - a) £¬Òò´Ëµ±·ÃÎʵ½Ò»¸ö prices[i] ÇÒ prices[i] - prices[i-1] > 0£¬ÄÇô¾Í°Ñ prices[i] - prices[i-1] Ìí¼Ó¼Óµ½ÊÕÒæÖУ¬´Ó¶øÔÚ¾Ö²¿×îÓŵÄÇé¿öÏÂÒ²±£Ö¤È«¾Ö×îÓÅ¡£ ```java public int maxProfit(int[] prices) {