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的更多相关文章

  1. LeetCode[3] Longest Substring Without Repeating Characters

    题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...

  2. [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  3. Longest Substring Without Repeating Characters

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  4. 3. Longest Substring Without Repeating Characters(c++) 15ms

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  5. 【leetcode】Longest Substring Without Repeating Characters

    题目描述: Given a string, find the length of the longest substring without repeating characters. For exa ...

  6. Longest Substring Without Repeating Characters(C语言实现)

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  7. leetcode: longest substring without repeating characters

    July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...

  8. [LeetCode_3] Longest Substring Without Repeating Characters

    LeetCode: 3. Longest Substring Without Repeating Characters class Solution { public: int lengthOfLon ...

  9. Longest Substring Without Repeating Characters (c#)

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  10. Longest Substring Without Repeating Characters(Difficulty: Medium)

    题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...

随机推荐

  1. 十一、Manipulators

    1. Manipulators是可以用三维进行绘制的的节点,可以将用户行为值化,对其他节点的属性进行modify. 2. 属性值可以通过Channel Box 和Graph Editor进行修改.同其 ...

  2. java反射,ReflectUtils

    public class ReflectUtils { /** * 通过构造函数实例化对象 * @param className 类的全路径名称 * @param parameterTypes 参数类 ...

  3. 对​O​p​e​n​C​V​直​方​图​的​数​据​结​构​C​v​H​i​s​t​o​g​r​a​m​的​理​解

    前几天被OpenCV的直方图的数据结构CvHistogram弄得很纠结.上网一搜,也没什么相关的资料.现在有点头绪了,就写点东西,让后面的人好走一些吧. 先来看看CvHistogram的定义: typ ...

  4. webstorm编辑RN代码提示功能

    需要下载一个文件. 1. 进入你想存储这个文件的目录,按住shift+鼠标右键,选择“在此处打开命令窗口” 2. 在命令窗口中输入  git clone https://github.com/virt ...

  5. Android test---JUnit

    JUnit 单元测试 Android的单元测试基础也是比较简单,同样还是测试相加方法是否正确,测试用例还是用1+1?=2来个简单的Android单元测试: 1..打开eclipse,新建一个proje ...

  6. jms的俩种模式

    package com.jiangchong.job; import java.util.Date; import javax.jms.Connection; import javax.jms.Con ...

  7. TENDA-F322路由器管理工具

    https://yunpan.cn/cYsfNxJLfVnUY (提取码:d0ae)

  8. C语言中extern的用法

    0x01 extern用在变量或函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”. 0x02 extern修饰变量的声明. 举例:若a.c中需引用b.c中的变量int v,可以在a. ...

  9. html尖角提示框的实现

    <style type="text/css">        .box {            background-color: #bebf22;          ...

  10. zt:synpify 综合,保持信号,时序处理

    http://www.actel.com/kb/article.aspx?id=TT1002 Logic Replication vs. Preserve Attributes in Synplici ...