罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值I 1V 5X 10L 50C 100D 500M 1000 例如, 罗马数字 2 写做 II ,即为两个并列的 1。12 写做 XII ,即为 X + II 。 27 写做 XXVII, 即为 XX + V + II 。 ...
分类:
其他好文 时间:
2020-07-28 00:14:49
阅读次数:
64
思路: 中序:左->根->右 1.需要一个建立一个栈,首先将左子树放入栈中 2.获取栈顶元素并进行节点判断是否有右子树 3. 代码: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode ...
分类:
其他好文 时间:
2020-07-27 23:50:51
阅读次数:
62
题目链接 https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/ 题解 递归解法 路径:一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。 这道题和LeetCode687最长同值路径和Leet ...
分类:
其他好文 时间:
2020-07-27 23:35:37
阅读次数:
74
题目 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器,且 n 的值至少为 ...
分类:
其他好文 时间:
2020-07-27 17:50:18
阅读次数:
71
Additive Number Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. ...
分类:
其他好文 时间:
2020-07-27 17:46:30
阅读次数:
60
题目描述 字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。请定义一个函数实现字符串左旋转操作的功能。比如,输入字符串"abcdefg"和数字2,该函数将返回左旋转两位得到的结果"cdefgab"。 示例: 输入: s = "abcdefg", k = 2 输出: "cdefgab" ...
分类:
其他好文 时间:
2020-07-27 16:03:49
阅读次数:
69
Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the s ...
分类:
其他好文 时间:
2020-07-27 15:58:17
阅读次数:
93
题目描述: 方法一:动态规划 O(mnlogmn) class Solution(object): def longestIncreasingPath(self, matrix): if not matrix or not matrix[0]: return 0 m, n = len(matrix) ...
分类:
其他好文 时间:
2020-07-27 15:46:06
阅读次数:
70
Given an array of positive integers target and an array initial of same size with all zeros. Return the minimum number of operations to form a target ...
分类:
其他好文 时间:
2020-07-27 15:38:31
阅读次数:
66
题目描述: 给定字符串 s 和 t ,判断 s 是否为 t 的子序列。 你可以认为 s 和 t 中仅包含英文小写字母。字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 ?100)。 字符串的一个子序列是原始字符串删除一些(也可以不删除)字符而不改变剩余字符相对位置形成 ...
分类:
其他好文 时间:
2020-07-27 13:58:41
阅读次数:
73