这道题目使用的方法具有非常大的普遍性,实际上是两个指针。一个指针记录当前所记录的子串的开始,另一个是当前遍历的位置,如果产生了重复,那么需要进行修正,实际上是对子串进行收缩。从当前子串开始位置到重复位置,重置相应的字符为违被搜索状态。在收缩之前需要进行,最长子串长度的更新。 1 public cla...
分类:
其他好文 时间:
2015-08-12 23:02:08
阅读次数:
121
问题描述: 给定两个序列 X=, Y,求X和Y长度最长的公共子串。(子串中的字符要求连续) 这道题和最长公共子序列(Longest common subsequence)很像,也可以用动态规划定义。公式如下:这里c[i,j]表示以Xi,Yj结尾的最长公共子串的长度。程序实现:int longes.....
分类:
其他好文 时间:
2015-08-12 21:13:28
阅读次数:
142
String path= this.getServletContext().getRealPath("") +request.getRequestURI().substring(request.getContextPath().length());(request.getContextPath()是...
分类:
其他好文 时间:
2015-08-12 01:11:02
阅读次数:
88
问题描述You are given a string,s, and a list of words,words, that are all of the same length. Find all starting indices of substring(s) insthat is a conca...
分类:
其他好文 时间:
2015-08-11 21:05:31
阅读次数:
109
问题描述Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter...
分类:
其他好文 时间:
2015-08-11 15:55:30
阅读次数:
88
JSONObjectobj=newJSONObject(); obj.put("password","123"); obj.put("test","123222"); Stringa=obj.toString(); obj.put("params",a.substring(1,a.length()-1)); System.out.println(obj);{"password":"123","test":"123222","params":"\"password\":\"123\",\"test\"..
分类:
Web程序 时间:
2015-08-10 20:17:06
阅读次数:
127
一、js中的substr和substring二、js获取url中的参数,还有for in的用法function getUrlParam(url){ // var href = window.Location.href.replace(/#+.*$/,''); //获取当前url,并去掉#+。*...
分类:
Web程序 时间:
2015-08-10 18:05:04
阅读次数:
128
1. 在JS中, 函数声明: stringObject.substring(start,stop) start是在原字符串检索的开始位置,stop是检索的终止位置,返回结果中不包括stop所指字符.如:"hamburger".substring(4,8) returns "urge"2.subst....
分类:
Web程序 时间:
2015-08-10 13:20:18
阅读次数:
95
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 "BAN...
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-08-09 01:57:22
阅读次数:
134