题目: Given a . For . 解题思路: 这个题让找一个字符串中具有不重复单词的最长子串的长度,如:ababc,子串为abc,长度为3.有这么几个方法: 方法一: 依赖字符串本身的一些特有函数,进行相应操作来完成.我们可以维护一个子串,来保存最长的无重复的子串,并记录当前子串的长度,如果遇到重复的字符,则去掉子串中重复的字符,一次进行下去,最终就能找到最长无重复子串.如str = ababc, substr = a, ab, ba, ab, abc....类似这样的思路.如下代码: /
--SQL 判断字段值是否有中文 create function fun_getCN(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1),@CN nvarchar(4000) set @CN='' while len(@str)>0 begin set @word=left(@str,1) i
--提取数字 IF OBJECT_ID('DBO.GET_NUMBER2') IS NOT NULL DROP FUNCTION DBO.GET_NUMBER2 GO )) ) AS BEGIN BEGIN ,'') END RETURN @S END GO --测试 PRINT DBO.GET_NUMBER('呵呵ABC123ABC') GO -------------------------------------------------------------------- --提取英文
Given a string, find the length of the longest substring without repeating characters.(请从子字符串中找出一个最长的不包含重复字符的子字符串) 首先定义函数f(i)表示以第i个字符结尾的不包含重复字符的子字符串的最大长度.我们从左到右扫描字符串中的每个字符.当我们计算第i个字符时,我们已经知道了f(i-1).如果第i个字符之前在字符串中没有出现过,那么f(i)=f(i-1) + 1,显然f(0)=1.如果第i个
Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explana