substrsubstr(start,length)表示从start位置开始,截取length长度的字符串。var src="images/pic_1.png";alert(src.substr(7,3));弹出值为:picsubstringsubstring(start,end)表示从start到...
分类:
其他好文 时间:
2015-08-18 11:51:07
阅读次数:
112
背景
最近开始研究算法,于是在leetcode上做算法题,第五题Longest Palindromic Substring便是关于回文子串的。
什么是回文字串
回文字符串是指将该字符串前后颠倒之后和该字符串一样的字符串。例如:a,aaaa,aba,abba…
最长回文子串
要求最长回文子串,就需要遍历每一个子串,时间复杂度是O(N²);判断字串是不是回文,时间复杂度是...
分类:
编程语言 时间:
2015-08-18 10:18:51
阅读次数:
172
最长公共子序列,英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。而最长公共子串(要求连续)和最长公共子序列是不同的。
#include "stdafx.h"
#include
#include
using names...
分类:
其他好文 时间:
2015-08-17 19:34:36
阅读次数:
116
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 le...
分类:
其他好文 时间:
2015-08-17 11:37:33
阅读次数:
123
String s = "abcdef";通过s.indexOf("c")函数,会返回一个int类型的索引值,此值代表字符“c”在此字符串中第一次出现的c的位置。s.lastIndexOf("c")函数,会返回最后一个出现“c”的位置subString代表了截取字符串的函数s.subString(in...
分类:
其他好文 时间:
2015-08-17 11:33:34
阅读次数:
99
题目
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is 3...
分类:
其他好文 时间:
2015-08-17 06:33:30
阅读次数:
232
leetcode -Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000,...
分类:
其他好文 时间:
2015-08-17 00:58:54
阅读次数:
112
最长公共子序列(LCS)是经典的DP问题,求序列a[1...n], b[1..m]的LCS。状态是DP[i][j],表示a[1..i],b[1..j]的LCS。DP转移方程是DP[i][j]= DP[i-1][j-1]+1, a[i] == b[j] max{ DP[i][j-1], DP[i...
分类:
其他好文 时间:
2015-08-17 00:39:46
阅读次数:
159
Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "a...
分类:
其他好文 时间:
2015-08-16 18:22:35
阅读次数:
102
首先,StringBuffer的toString方法和String的subString方法都是在新生成了一个新的String。 最近做的一个功能,多线程的从SQLite数据库中读取数据。将数据拼成在MySQL中可以批量执行的SQL语句,再多线程地插入到MySQL中。
分类:
其他好文 时间:
2015-08-16 12:09:50
阅读次数:
123