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: ...
随机推荐
- 十一、Manipulators
1. Manipulators是可以用三维进行绘制的的节点,可以将用户行为值化,对其他节点的属性进行modify. 2. 属性值可以通过Channel Box 和Graph Editor进行修改.同其 ...
- java反射,ReflectUtils
public class ReflectUtils { /** * 通过构造函数实例化对象 * @param className 类的全路径名称 * @param parameterTypes 参数类 ...
- 对OpenCV直方图的数据结构CvHistogram的理解
前几天被OpenCV的直方图的数据结构CvHistogram弄得很纠结.上网一搜,也没什么相关的资料.现在有点头绪了,就写点东西,让后面的人好走一些吧. 先来看看CvHistogram的定义: typ ...
- webstorm编辑RN代码提示功能
需要下载一个文件. 1. 进入你想存储这个文件的目录,按住shift+鼠标右键,选择“在此处打开命令窗口” 2. 在命令窗口中输入 git clone https://github.com/virt ...
- Android test---JUnit
JUnit 单元测试 Android的单元测试基础也是比较简单,同样还是测试相加方法是否正确,测试用例还是用1+1?=2来个简单的Android单元测试: 1..打开eclipse,新建一个proje ...
- jms的俩种模式
package com.jiangchong.job; import java.util.Date; import javax.jms.Connection; import javax.jms.Con ...
- TENDA-F322路由器管理工具
https://yunpan.cn/cYsfNxJLfVnUY (提取码:d0ae)
- C语言中extern的用法
0x01 extern用在变量或函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”. 0x02 extern修饰变量的声明. 举例:若a.c中需引用b.c中的变量int v,可以在a. ...
- html尖角提示框的实现
<style type="text/css"> .box { background-color: #bebf22; ...
- zt:synpify 综合,保持信号,时序处理
http://www.actel.com/kb/article.aspx?id=TT1002 Logic Replication vs. Preserve Attributes in Synplici ...