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: ...
随机推荐
- Nodejs创建客户端
Node 创建 Web 客户端需要引入 http 模块,创建 client.js 文件,代码如下所示: var http = require('http'); //用于请求的选项 var option ...
- LR12.53—第5课:创建负载测试场景
在前面的课程中,您使用VuGen将验证您的Vuser脚本.在本课中,您将评估多个Vuser的负载下您的系统.您将模拟十个旅行代理同时使用航班预订系统的行动,以及这些用户的负载下观察系统的行为.设计和运 ...
- JQuery lhgdialog使用
jQuery方式调用 J ); testDG4.SetPosition( 'center', 'center' );}; var testDG4 = J('#btn26').dialog({ id:' ...
- java 静态代码块 构造块 构造方法
class className{ static{ }//静态代码块 { }//构造代码块 public className(){} //构造方法 }
- HBase的伪分布式安装(原创)
准备工作: 1)安装了伪分布式hadoop:参照http://blog.csdn.net/zolalad/article/details/11472207 2)修改已安装好的hadoop配置文件: a ...
- 4中map遍历的方法
public static void main(String[] args) { Map<String, String> map = new HashMap<String, Stri ...
- Winform 委托窗体传值
有窗体Form1和窗体Form2,单击Form1按钮弹出Form2,单击Form2吧Form2的textBox控件文本传给Form1的label控件. 窗体1里: 实例化Form2,注册Form2的事 ...
- Linux 驱动学习笔记05--字符驱动实例,实现一个共享内存设备的驱动
断断续续学驱动,好不容易有空,做了段字符驱动的例子.主要还是跟书上学习在此记录下来,以后说不定能回过头来温故知新. 首先上驱动源码 gmem.c: /************************* ...
- 【转】解决IIS7该问.svc文件的错误问题
解决IIS7.5中部署WCF时,访问.svc文件的404错误问题如果你直接在IIS 7中配置WCF,访问.svc文件时会出现404错误.解决方法,以管理员身份进入命令行模式,运行:" ...
- iOS 类的判断方法
-(BOOL) isKindOfClass: classObj 用来判断是否是某个类或其子类的实例 -(BOOL) isMemberOfClass: classObj 用来判断是否是某个类的实例 -( ...