3 Longest Substring Without Repeating Characters
public int lengthOfLongestSubstring(String s) {
long length = s.length();
String tmp = "";
int substringLength = 0;
for (int i = 0; i < length; i ++) {
if (tmp.contains(("" + s.charAt(i)))) {
if (tmp.length() > substringLength)
substringLength = tmp.length();
int idx = tmp.indexOf(s.charAt(i) + "");
tmp = tmp.substring(idx + 1) + s.charAt(i);
}
else {
tmp = tmp + s.charAt(i);
if (substringLength < tmp.length())
substringLength = tmp.length();
}
}
return substringLength;
}
3 Longest Substring Without Repeating Characters的更多相关文章
- LeetCode[3] Longest Substring Without Repeating Characters
题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串
Given a string, find the length of the longest substring without repeating characters. For example, ...
- Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- 3. Longest Substring Without Repeating Characters(c++) 15ms
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- 【leetcode】Longest Substring Without Repeating Characters
题目描述: Given a string, find the length of the longest substring without repeating characters. For exa ...
- Longest Substring Without Repeating Characters(C语言实现)
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- leetcode: longest substring without repeating characters
July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...
- [LeetCode_3] Longest Substring Without Repeating Characters
LeetCode: 3. Longest Substring Without Repeating Characters class Solution { public: int lengthOfLon ...
- Longest Substring Without Repeating Characters (c#)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- Longest Substring Without Repeating Characters(Difficulty: Medium)
题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...
随机推荐
- div,li,span自适应宽度换行问题
<ul class="news"> <li><span class="lbl">右对齐,换行显示的解决方法</s ...
- Linux里的2>&1
我们在Linux下经常会碰到nohup command>/dev/null 2>&1 &这样形式的命令.首先我们把这条命令大概分解下首先就是一个nohup表示当前用户和系统 ...
- windows下react-native android打包笔记
看了东方耀老师的视频,跟着记下了以下笔记,其实和东方耀老师的课堂笔记差不多,增加了一点细节 1. 生成一个签名密钥: 在项目目录下运行 keytool -genkey -v -keystore my- ...
- 如何判断js中的数据类型
如何判断js中的数据类型:typeof.instanceof. constructor. prototype方法比较 如何判断js中的类型呢,先举几个例子: var a = "iamstri ...
- C#笔试(程序设计)
1.如何把一个Array复制到ArrayList里,如何把ArrayList复制到Array里? foreach( object o in array )arrayList.Add(o); Array ...
- NET 强签名
强签名: 1. 可以将强签名的dll注册到GAC,不同的应用程序可以共享同一dll. 2. 强签名的库,或者应用程序只能引用强签名的dll,不能引用未强签名的dll,但是未强签名的dll可以引用强签名 ...
- EasyUI TextBox的onkeypress事件
关于EasyUI TextBox的事件好像不多,像keypress,keydown在textbox的事件里都没有,所以要用这些事件要采取一些特殊的方法,今天用到了这些就记录一下,有两种方法 方法1: ...
- CMake比较实用的命令小记
最近将项目迁移到CMake进行管理,对CMake进行了一些研究,觉得有一些命令非常实用但很少有资料提到,在这里做一个总结,至于太普通常用的命令就不提了. OPTION(OPTION_VAR " ...
- ExtJs6.0.0随笔
环境:extJs6.0.0GPL,对应SenchaCmd-6.0.2-windows-64bit(注意版本不能太高). 步骤: 1.安装senchaCmd 2.运行生成demo: http://doc ...
- Python: 字典的基本操作
字典是Python里唯一的映射类型.字典是可变的.无序的.大小可变的键值映射,有时候也称为散列表或关联数组. 例子在下面: dic = {"apple":2, "oran ...