Given a string, find the length of the longest substring T that contains at most k distinct characters. Example 1: Input: s = "eceba", k = 2 Output: 3 ...
分类:
其他好文 时间:
2018-12-10 13:56:45
阅读次数:
179
"""32. Longest Valid ParenthesesHard134368 Given a string containing just the characters '(' and ')', find the length of the longest valid (well-forme ...
分类:
其他好文 时间:
2018-12-09 20:05:49
阅读次数:
159
五星方法如下: key : min max sorted function :filter map normal: reversed zip zip_longest globals locals print sum repr reduce 四星方法: bytes abs divmod 1、min:返 ...
分类:
其他好文 时间:
2018-12-09 18:44:01
阅读次数:
175
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe ...
分类:
编程语言 时间:
2018-12-09 12:11:27
阅读次数:
209
linux split 命令 功能说明:切割文件。 语 法:split [--help][--version][-<行数>][-b <字节>][-C <字节>][-l <行数>][要切割的文件][输出文件名] 补充说明:split可将文件切成较小的文件,预设每1000行会切成一个小文件。 参 数: ...
分类:
系统相关 时间:
2018-12-08 19:08:24
阅读次数:
229
// O(nlogn) class Solution { public: int lengthOfLIS(vector& nums) { int n = nums.size(); if (n dp; dp.push_back(nums[0]); for (int i = 1; i & nums) {... ...
分类:
其他好文 时间:
2018-12-08 15:43:09
阅读次数:
164
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" string longestPalindrome(string ...
分类:
其他好文 时间:
2018-12-06 22:18:59
阅读次数:
203
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This ...
分类:
编程语言 时间:
2018-12-06 10:19:11
阅读次数:
242
Description A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence ...
分类:
其他好文 时间:
2018-12-04 22:37:47
阅读次数:
290
方法一: 最容易想到的就是一个个比,如果不一样,那么前面的就是最长公共前缀。 为了防止下标越界等情况,先把最短的字符找出来,作为基准用来一位位比较。 方法二:Trie 虽然在这道题里trie的优势没有体现出来,但还是写了一下,就当复习Trie。 找最长公共前缀也很容易,只要找到 next数组里有超过 ...
分类:
其他好文 时间:
2018-12-03 15:38:36
阅读次数:
219