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: ...
随机推荐
- virtualbox桥接网络配置--CentOS
系统安装好后如下图设置virtualbox虚拟机的网络连接方式 然后启动虚拟机 ifconfig发现如下图 vi /etc/sysconfig/network-scripts/ifcfg-eth0 根 ...
- AE IRasterCursor 改变栅格图层像素值
1 public void ChangePixelValue(double xMax, double xMin, double yMax, double yMin,double[,] PixelCha ...
- vs2012中添加lib,.h文件方法(原)
项目.属性.C/C++.附加包含目录:填写附加头文件(*.h)所在目录 分号间隔多项项目.属性.链接器.附加库目录:填写附加依赖库(*.lib)所在目录 分号间隔多项项目.属性.链接器(点前面的+展开 ...
- FPGA综合工具--Synplify Pro的常用选项及命令
最近要用到Synplify,但以前没使用过,无基础,找到一篇帖子,隧保存下来. 本文转自:http://blog.sina.com.cn/s/blog_65fe490d0100v8ax.html Sy ...
- LRU implement Data Structure analysis
三种数据结构实现的LRU对比分析: 自适应循环链表, 跳表 和 伸展树 对比发现 : 跳表比其他两个会好一些(命中率) 来自论文 Performance Analysis of LRU
- Ambari 不能配置 Kafka 监听host的问题
问题:Ambari下Kafka多IP监听配置 环境:Ambari 1.7.0 , Hadoop 2.2 Kafka 0.8.1.2.2.0.0 现象: Ambari 中是不能配置Kafka的host. ...
- 7、IMS - DNS & ENUM
1.相关基础SBC:http://blog.sina.com.cn/s/blog_7a6f76080100vp9r.html 2.ENUM/DNS查询过程:http://blog.sina.com.c ...
- jquery用append添加按钮之后,按钮监听无法使用的解决方法
<!DOCTYPE html><html><head><meta charset="utf-8"> <title>< ...
- cut命令
cut是一个选取命令,就是将一段数据经过分析,取出我们想要的.一般来说,选取信息通常是针对"行"来进行分析的,并不是整篇信息分析的. (1)其语法格式为:cut [-bn] [f ...
- Java日志——2016年5月30日
1. 局部变量必须初始化,可以定义的同时初始化,也可以定义完成之后进行初始化. 2. Java7新特性:数字之间可以使用"_"连接,eg:23_44_5 = 23445,0B110 ...