2019年3月23日

leetcode_1015. Numbers With Repeated Digits

摘要: https://leetcode.com/problems/numbers-with-repeated-digits/ 与leetcode_357. Count Numbers with Unique Digits有一些相似的地方。 给定N,计算小于等于N且至少有一个重复数位的数的数目。 可转化为计 阅读全文

posted @ 2019-03-23 20:54 JASONlee3 阅读(176) 评论(0) 推荐(0)

leetcode_357. Count Numbers with Unique Digits

摘要: https://leetcode.com/problems/count-numbers-with-unique-digits/ 给定一个n,计算[0,10^n]中十进制中每一位都不相同的数的数目。 阅读全文

posted @ 2019-03-23 20:29 JASONlee3 阅读(160) 评论(0) 推荐(0)

leetcode_712. Minimum ASCII Delete Sum for Two Strings

摘要: https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/ 给定两个string s1,s2,从s1和s2中删除一些字符,使s1和s2相同,并且要求删除的所有字符的ASCLL码之和最小。 解法: 找出s1和s2的公共 阅读全文

posted @ 2019-03-23 20:24 JASONlee3 阅读(129) 评论(0) 推荐(0)

leetcode_865. Smallest Subtree with all the Deepest Nodes

摘要: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/ 给定一颗二叉树,输出包含所有最深叶子结点的最小子树的根节点。 解法一: 先使用dfs计算最大深度deep和最大深度的叶子结点数cnt,然后后序遍历,对 阅读全文

posted @ 2019-03-23 20:13 JASONlee3 阅读(182) 评论(0) 推荐(0)

leetcode_919. Complete Binary Tree Inserter

摘要: https://leetcode.com/problems/complete-binary-tree-inserter/ 设计一个CBTInserter,使用给定完全二叉树初始化。三个功能; CBTInserter(TreeNode root) initializes the data struct 阅读全文

posted @ 2019-03-23 12:25 JASONlee3 阅读(132) 评论(0) 推荐(0)

leetcode_1014. Capacity To Ship Packages Within D Days

摘要: https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/ 传送带要在D天内把所有货物传送完,但是传送带每天有传送容量的限制,问保证货物在D天内传送完的最小容量限制。货物重量以weights[]给出。 一开始想从wei 阅读全文

posted @ 2019-03-23 11:20 JASONlee3 阅读(153) 评论(0) 推荐(0)

leetcode_998. Maximum Binary Tree II

摘要: https://leetcode.com/problems/maximum-binary-tree-ii/ 在654. Maximum Binary Tree版本的建树基础上,在最后插入一个数。 新节点要么为根节点,原树为其左子树;要么将新节点插在右子树中。 阅读全文

posted @ 2019-03-23 10:54 JASONlee3 阅读(90) 评论(0) 推荐(0)

leetcode_654. Maximum Binary Tree

摘要: https://leetcode.com/problems/maximum-binary-tree/ 给定数组A,假设A[i]为数组最大值,创建根节点将其值赋为A[i],然后递归地用A[0,i-1]创建左子树,用A[i+1,n]创建右子树。 使用vector的assign函数,该函数的特性: Any 阅读全文

posted @ 2019-03-23 10:33 JASONlee3 阅读(79) 评论(0) 推荐(0)

leetcode_894. All Possible Full Binary Trees

摘要: https://leetcode.com/problems/all-possible-full-binary-trees/ 给定节点个数,求所有可能二叉树,该二叉树所有节点要么有0个子节点要么有两个子节点。返回所有二叉树的头指针。 一开始一直想的是从根节点开始建树,一直想不出来方法。后来想到可以从子 阅读全文

posted @ 2019-03-23 10:07 JASONlee3 阅读(104) 评论(0) 推荐(0)

导航