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 ...
分类:
其他好文 时间:
2016-04-25 20:55:00
阅读次数:
129
Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the roo ...
分类:
其他好文 时间:
2016-04-25 00:37:34
阅读次数:
142
例子: 3,8,4,5,6,2 返回值应该为 :5 这是昨天做的一道优酷土豆的编程题,和leetcode中的128/ Longest Consecutive Sequence 有点相似,但是leetcode题的公差是确定的1,而这道题的公差是不确定的。 本人的写出的是一种通过穷举的方法实现查找最长等 ...
分类:
其他好文 时间:
2016-04-24 20:07:44
阅读次数:
722
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2016-04-23 11:33:14
阅读次数:
209
Longest Palindromic Substring 最长回文子串 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 100 ...
分类:
其他好文 时间:
2016-04-22 18:25:01
阅读次数:
147
1. 二叉查找树 二叉查找树(Binary Search Tree)/ 有序二叉树(ordered binary tree)/ 排序二叉树(sorted binary tree) 1). 若任意节点的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 2). 若任意节点的右子树不空,则右子树上 ...
分类:
编程语言 时间:
2016-04-22 16:04:12
阅读次数:
205
Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is "ece" whi ...
分类:
其他好文 时间:
2016-04-22 13:24:06
阅读次数:
159
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 ...
分类:
其他好文 时间:
2016-04-20 21:35:38
阅读次数:
146
题意为给出一个字符串,找出其中没有重复字符的最长子序列的长度。brute force的复杂度为O(n^3).依次查找每个子字符串是否含有重复字符,并比较长度。开始看到题目,想用DP解决,在已有目前最长子序列的情况下,比较把当前字符串放入和不放入,那个子序列长度会更大,但是这种解法的复杂度为O(n^2 ...
分类:
其他好文 时间:
2016-04-19 00:09:11
阅读次数:
127
Write a function to find the longest common prefix string amongst an array of strings. []=>""["abcweed","htgdabc","sabcrf"]=>""["abcweed","abhtgdc","a ...
分类:
其他好文 时间:
2016-04-18 11:38:56
阅读次数:
129