LeetCode 1372. Longest ZigZag Path in a Binary Tree二叉树中的最长交错路径【Medium】【Python】【DFS】 Problem "LeetCode" Given a binary tree , a ZigZag path for a binar ...
分类:
编程语言 时间:
2020-03-08 15:55:09
阅读次数:
79
Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must ...
分类:
其他好文 时间:
2020-03-08 09:32:42
阅读次数:
81
``` class Solution: def lengthOfLongestSubstring(self, s: str) -> int: # outlier if s == "": return 0 if len(s) == 1: return 1 max_i = 0 start = 0 end... ...
分类:
其他好文 时间:
2020-03-06 20:22:22
阅读次数:
56
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: ...
分类:
其他好文 时间:
2020-03-05 11:52:43
阅读次数:
60
转自:labuladong公众号 很多读者反应,就算看了前文 动态规划详解,了解了动态规划的套路,也不会写状态转移方程,没有思路,怎么办?本文就借助「最长递增子序列」来讲一种设计动态规划的通用技巧:数学归纳思想。 最长递增子序列(Longest Increasing Subsequence,简写 L ...
分类:
编程语言 时间:
2020-03-05 01:00:26
阅读次数:
71
思路 0. 首先思考什么时候产生LIS上升的贡献,肯定是遇到了一个小于号啊,左边 4 大于号肯定不产生LIS的贡献了,。 假设上面想到了。 接下来考虑怎么找最短,和最长。 再等等,思考还有没有产生贡献的地方? 容易想到就是 小于号 与 小于号 之间 也会产生贡献。 比如 3424 using nam ...
分类:
其他好文 时间:
2020-02-29 17:34:26
阅读次数:
71
最多有K个不同字符的最长子串。题意就不解释了,参见159题。例子, Example 1: Input: s = "eceba", k = 2 Output: 3 Explanation: T is "ece" which its length is 3. Example 2: Input: s = ...
分类:
其他好文 时间:
2020-02-28 15:37:15
阅读次数:
51
最多有两个不同字符的最长子串。题意是给一个字符串,请返回一个最长子串的长度。子串的要求是最多只有两个不同的字母。例子, Example 1: Input: "eceba" Output: 3 Explanation: tis "ece" which its length is 3. Example ...
分类:
其他好文 时间:
2020-02-28 13:52:03
阅读次数:
68
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example... ...
分类:
其他好文 时间:
2020-02-27 11:41:45
阅读次数:
73