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. gcc for windows(mingw)编译多个c文件

    myString.c myString.h main.c 其中,myString.c与myString.h对应,myString.h文件中是一些函数的声明,而myString.c文件中是.h文件中声明 ...

  2. 数据库使用--MySQL: InnoDB 还是 MyISAM?

    MyISAM存储引擎 MyISAM是 默认存储引擎.它基于更老的ISAM代码,但有很多有用的扩展.MyISAM存储引擎的一些特征: ·      所有数据值先存储低字节.这使得数据机和操作系统分离.二 ...

  3. 安装spf13-vim on Windows10

    安装之前 1.系统为 windows10  Version 1607 64位 企业版 2.参考 http://www.codeweblog.com/gvim-64%E4%BD%8D-windows-7 ...

  4. ubuntu修改设备名称

    按住ctrl+alt+t打开终端 输入 sudo gedit /etc/hostname 出现一个打开的文件,显示的就是你的设备名字,也就是终端@的那个名字.将其修改成你想显示的名字,保存重启系统就可 ...

  5. pom.xml详解

    setting.xml主要用于配置maven的运行环境等一系列通用的属性,是全局级别的配置文件:而pom.xml主要描述了项目的maven坐标,依赖关系,开发者需要遵循的规则,缺陷管理系统,组织和li ...

  6. 从一个复杂的json格式的String内获取某key的值

    如题,如何简单的从一个复杂的String格式内获取某个key的值. 例如:从下面String下取到status的值. {"response":{"info":{ ...

  7. PHP实现异步调用方法研究

    作者: Laruence 本文地址: http://www.laruence.com/2008/04/14/318.html 转载请注明出处 , ,); curl_setopt_array(, ); ...

  8. Bash Shell的操作环境

    1.路径与命令查找顺序 基本上,命令运行的顺序可以这样看: 1)以相对/绝对路径执行命令,例如“/bin/ls”或“./ls”; 2)由alias找到该命令来执行; 3)由bash内置的(builti ...

  9. nagios二次开发(一)---开发思想

    NAGIOS现状   从nagios的官网http://www.nagios.org/及其它已经公开的资料,我们可以知道:在web UI层nagios只提供了给我们查看图形界面的操作,界面上有简单的启 ...

  10. visual c++ 2010安装失败导致CRM2015安装失败

    记录一下: 今天重新安装CRM2015时碰到以下错误: 安装一个或多个缺少的必备组件失败...,查看日志发现是 Microsoft Visual C++ 运行时 的安装失败,但查看系统发现vc++20 ...