Given a binary tree, findits maximum depth.
The maximum depth is thenumber of nodes along the longest path from the root node down to the farthestleaf node.
可用递归,效率低。
这里用类似层次遍历的算法。设置一个队列和两个int变量...
分类:
其他好文 时间:
2015-01-30 09:10:56
阅读次数:
261
题目链接:Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
这道题的要求是在字符串数组中找到最长公共前缀。
思路比较简单,就是两个字符串逐个比较,找最长公共子串。这里采用将每个字符串都与第一个字符串相比较,求最长子串。
时间...
分类:
其他好文 时间:
2015-01-29 21:13:30
阅读次数:
197
原题地址双指针法。右指针不断向右试探,当遇到重复字符时停下来,此时左指针开始向右收缩,直到去掉那个重复字符。代码: 1 int lengthOfLongestSubstring(string s) { 2 map record; 3 int maxLen = 0; 4...
分类:
其他好文 时间:
2015-01-29 19:20:25
阅读次数:
140
Java中的substring()方法有两个方法的重载,一个带一个参数的,一个带两个参数的。 第一种写法: substring(n);//从索引是n的字符开始截取,条件(n>=0,n<字符串长度),第一个字符的索引是0 。n作为第一个参数,必须小于字符串长度,因为这边是从包含n下边开始截取的,所.....
分类:
数据库 时间:
2015-01-29 17:28:14
阅读次数:
375
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once
and without ...
分类:
其他好文 时间:
2015-01-29 14:41:06
阅读次数:
91
在项目中用到了Oracle中Instr这个函数,顺便仔细的再次学习了一下这个知识。Oracle中,可以使用Instr函数对某个字符串进行判断,判断其是否含有指定的字符。其语法为:Instr(string, substring, position, occurrence)其中string:代表源字符串...
分类:
数据库 时间:
2015-01-29 14:12:25
阅读次数:
223
IE版本不同对jquery substr和substring解析不同今天发现IE版本不同对jquery substr和substring解析不同1.在火狐,360,IE9及以上版本string.trim().substr(0,5)得到的是,5字符2.在IE8及以下得到的是3个3. 不加trim() ...
分类:
Web程序 时间:
2015-01-29 12:16:59
阅读次数:
162
常用的mysql截取函数有:left(), right(), substring(), substring_index()下面来一一说明一下:1.左截取left(str, length)2.右截取right(str, length)3.substring(str, pos); substring(s...
分类:
数据库 时间:
2015-01-28 19:27:11
阅读次数:
173
问题描述:
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is...
Total Accepted: 1167
Total Submissions: 3961
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...
分类:
其他好文 时间:
2015-01-28 06:15:59
阅读次数:
149