
LeetCode
明灵暗尘
这个作者很懒,什么都没留下…
展开
-
Leetcode_DP_198_HouseRobber
CatalogureDescriptionThinkingCode Description Thinking Initial State: dp[0] = nums[0], dp[1] = nums[1]; State Transformation Equation: dp[i] = max{dp[i-1], dp[i-2]+nums[i]}; Code class Solution { pu...原创 2019-07-29 13:11:19 · 167 阅读 · 0 评论 -
Leetcode_DP_53_MaximumSubarray
CatalogueDescriptionThinkingState transformation equationCode Description Thinking State transformation equation dp[i] = max{num[i], dp[i-1]+dp[i-1]} Code class Solution { public: int maxSubArra...原创 2019-07-28 20:57:11 · 115 阅读 · 0 评论 -
Leetcode_DP_303_RangeSumQuery(Immutable)
CatalogueDescriptionThinkingCode Description Thinking Violent Solution Creating a two-dimensional array dp where dp[i][j] denotes the sum of the elements between indices i and j. Dynamic Programmi...原创 2019-07-28 19:25:21 · 104 阅读 · 0 评论 -
Leetcode_DP_121_BestTimeToBuyAndSellStock
CatalogueDescriptionThinkingState: dp[i], dp[1] = false, dp[2] = true;Transformation equation:dp[i] = (N / j == 0 && dp[j]) ?? true : false;Code Description Thinking Let us assume a one-dimen...原创 2019-07-28 16:46:20 · 99 阅读 · 0 评论 -
Leetcode_DP(level_M)_413_ArithmeticSlices
CatalogueDescriptionThinkingCode Description Thinking Violent solution i traverses from 1 to n while j traverses from i-1 to 0. When j+1 equal to i, the default equal difference is A[i] - A[j], and ...原创 2019-08-01 20:59:27 · 119 阅读 · 0 评论 -
Leetcode_DP(level_M)_712_MinimumASCIIDeleteSumForTwoStrings
CatalogueDescriptionThinkingCode Description Thinking Tips: We will traverse both of two strings, if s1[i] != s2[j], we must delete one of them to minimize the ASCII. State: dp[i][j] denotes the mini...原创 2019-08-01 00:04:46 · 117 阅读 · 0 评论 -
Leetcode_DP(level_M)_647_PalindromicSubstrings
CatalogueDescriptionThinkingCode Description Thinking Plan A (Two-dimensional, from top to bottom) State: dp[i][j] denotes whether the substring whose indices from i to j is a palindrom. Transformati...原创 2019-07-31 21:32:07 · 125 阅读 · 0 评论 -
Leetcode_DP(level_M)_120_Triangle
CatalogueDescriptionThinking Description Thinking Plan A (Two-dimensional, from top to bottom) State: dp[i][j] denotes the minimum distance from top to triangle[i][j] Transformation equation : dp[i][...原创 2019-07-31 19:56:59 · 116 阅读 · 0 评论 -
Leetcode_DP(level_M)_877_StoneGame
CatalogueDescriptionThinkingCodeConclusion Description Thinking Sorry, I have no idea yet about how to solve this problem with a one-dimensional array right now. Maybe I’ll follow up at another time ...原创 2019-07-29 17:02:43 · 168 阅读 · 0 评论 -
Leetcode_UnionFind(level_M)_200_547
CatalogueDescription_200_number-of-islandsDescription_547_friend-circlesThinkingCode Description_200_number-of-islands Description_547_friend-circles Thinking Something In Common Both of two questio...原创 2019-08-08 21:41:20 · 180 阅读 · 0 评论