Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2018-06-18 17:15:52
阅读次数:
170
问题描述: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. ...
分类:
其他好文 时间:
2018-06-17 10:57:20
阅读次数:
142
传送门 题目 In one well-known algorithm of finding the k-th order statistics we should divide all elements into groups of five consecutive elements and fin ...
分类:
其他好文 时间:
2018-06-17 10:51:56
阅读次数:
191
描述Write a function to find the longest common prefix string amongst an array of strings.分析从位置 0 开始,对每一个位置比较所有字符串,直到遇到一个不匹配。 代码 ...
分类:
其他好文 时间:
2018-06-16 17:04:03
阅读次数:
137
描述Given a string S, find the longest palindromic substring in S. You may assume that the maximumlength of S is 1000, and there exists one unique longe ...
分类:
其他好文 时间:
2018-06-13 23:42:30
阅读次数:
316
问题介绍 给定一个序列$X=$,另一个序列$Z=$满足如下条件时称为X的 子序列 :存在一个严格递增的X的下标序列$$,对所有的$j=1,2,...,k$满足$x_{i_j}=z_j.$ 给定两个序列$X$和$Y$,如果$Z$同时是$X$和$Y$的子序 ...
分类:
其他好文 时间:
2018-06-12 16:13:02
阅读次数:
229
最近在看流畅的python,在看第14章节的itertools模块,对其itertools中的相关函数实现的逻辑的实现其中在zip_longest(it_obj1, ..., it_objN, fillvalue=None)时,其函数实现的功能和内置zip函数大致相同(实现一一对应),不过内置的zip函数是已元素最少对象为基准,而zip_longest函数是已元素最多对象为基准,使用fillval
分类:
编程语言 时间:
2018-06-11 17:18:39
阅读次数:
244
看到这个题第一反应是做过啊,然后就开始写,等写完一测。emmmmm,原来是最长回文子串不是最长回文子序列,但是写都写了,我就把代码稍微修改了一下让适应于该题目,代码如下: 然后这个代码一看就很搓啊,完全不适应该题,猜测效率一定很低,等提交过后看,果不其然,只超过了13.74%的代码。只好删了重写。 ...
分类:
编程语言 时间:
2018-06-11 02:09:30
阅读次数:
180
题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=1318 这道题的大意是要求一个长度为len,并包含1~len所有数,并使len最大的子区间。开始看题的时候一脸懵逼(好像可以二分?),然后写到一半突然发现二分有反例。 于是上网搜了一波题解 ...
分类:
其他好文 时间:
2018-06-10 23:07:54
阅读次数:
263
A string is finite sequence of characters over a non empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called fa ...
分类:
其他好文 时间:
2018-06-10 11:42:53
阅读次数:
162