上一页 1 ··· 75 76 77 78 79 80 81 82 83 ··· 114 下一页
摘要: 补充一个python的实现: 这道题的思路是,从1到n,依次选择某节点作为根节点。假设n=2, 1为根节点:比1小的元素有0个,比1大的元素有1个,因此有dp[0]*dp[1] 2为根节点:比2小的元素有1个,比2大的元素有0个,因此有dp[1]*dp[0] 这两种情况之和,即为dp[2]。 再假设 阅读全文
posted @ 2018-10-11 19:23 Sempron2800+ 阅读(144) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: TreeNode* pruneTree(TreeNode* root) { if(root==NULL) { return nullptr; } if(root->left!=NULL) { root->left... 阅读全文
posted @ 2018-10-10 14:11 Sempron2800+ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int MonotoneIncreasingDigits(int N) { var num = N.ToString(); var len = num.Length; if (len == 1) { ... 阅读全文
posted @ 2018-10-09 20:40 Sempron2800+ 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 利用数学公式解题。 阅读全文
posted @ 2018-10-09 15:22 Sempron2800+ 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 本题使用贪心算法思想,这里给出的代码是比较高效的一种解法。 阅读全文
posted @ 2018-10-09 12:13 Sempron2800+ 阅读(121) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int MatrixScore(int[][] A) { var row = A.GetLength(0); var col = A[0].GetLength(0); //判断最高位是否为1 for ... 阅读全文
posted @ 2018-10-09 11:31 Sempron2800+ 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 补充一个python的实现,写的要简单的多了: 阅读全文
posted @ 2018-10-08 18:38 Sempron2800+ 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 原来的实现中没有加"|"对code进行分割,这样的代码也可以ac,但是会有隐藏的bug,那就是如下两个串会得到相同的编码: abcdefghijklmn abcdefghijbabbbcbd 两个字符串都会编码为012345678910111213,加了竖线就不会再有这个bug。 阅读全文
posted @ 2018-10-08 00:21 Sempron2800+ 阅读(140) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: TreeNode* constructMaximumBinaryTree(vector& nums) { if (nums.size() == 0) return NULL; else if (nums.size() == 1) ... 阅读全文
posted @ 2018-10-07 23:42 Sempron2800+ 阅读(98) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int maxIncreaseKeepingSkyline(vector>& grid) { //找出每一行的最大值 const int N = 50; int ROW_HEIGHT[N]; int COL_HEIGHT[N]; int MIX_HEIGHT[... 阅读全文
posted @ 2018-10-07 23:29 Sempron2800+ 阅读(88) 评论(0) 推荐(0) 编辑
上一页 1 ··· 75 76 77 78 79 80 81 82 83 ··· 114 下一页