摘要: 本题是动态规划的题目,vec[i,j]记录的是以matrix[i,j]为右下角的所能构成的正方形区域的边长的最大值。 递推公式,vec[i][j] = 1 + min(min(vec[i-1][j],vec[i][j-1]),vec[i-1][j-1]),计算的是当前单元格的“左”、“上”、“左上” 阅读全文
posted @ 2018-10-14 20:06 Sempron2800+ 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Java实现如下: public class Solution { public int coinChange(int[] coins, int amount) { if (amount == 0) return 0; int[] dp = new int[amount + 1]; dp[0] = 阅读全文
posted @ 2018-10-14 20:03 Sempron2800+ 阅读(205) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int MinAddToMakeValid(string S) { Stack ST = new Stack(); foreach (var s in S) { if (s.Equals('(... 阅读全文
posted @ 2018-10-14 19:54 Sempron2800+ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int[] SortArrayByParityII(int[] A) { var len = A.Length; int[] ODD = new int[len / 2];//奇数1,3,5,7,9 int[] EVEN =... 阅读全文
posted @ 2018-10-14 19:43 Sempron2800+ 阅读(114) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* sortList(ListNode* head) { multimap mul; while(head){ mul.insert(make_pair(head->val,head)); head=head->next; } ... 阅读全文
posted @ 2018-10-14 00:31 Sempron2800+ 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 补充另一种写法: 参考:https://leetcode.com/problems/partition-equal-subset-sum/discuss/90592/01-knapsack-detailed-explanation 先上一张图:测试数据为nums=[1,3,3,5],判断是否可以分割 阅读全文
posted @ 2018-10-14 00:25 Sempron2800+ 阅读(181) 评论(0) 推荐(0) 编辑