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. adb 命令集合

    1. adb shell 2. adb version 查看 adb 安装版本 3. adb start-server 启动服务 4. adb kill-server 杀死服务 5. adb get- ...

  2. 安装fast cgi

    1. 下载 在HTTPD主页,找到"mod_fcgid" 下载“mod_fcgid-2.3.9-crlf.zip” 2. 生成so文件 首先,设置APACHE2_HOME系统变量. ...

  3. GNU/Linux复习笔记(2)

    ---IO重定向: 典型的冯诺依曼计算机由5大部件组成:运算器,控制器,存储器,输入设备和输出设备.而一台计算机上可能有很多输入设备和输出设备,键盘.麦克风是输入设备,显示器.声卡是输出设备,网卡.硬 ...

  4. sencha touch打包成安装程序

    为了更好地向大家演示如何打包一个sencha touch的项目,我们用sencha cmd创建一个演示项目,如果你的sencha cmd环境还没有配置,请参照 sencha touch 入门系列 (二 ...

  5. web开发过程中经常用到的一些公共方法及操作

    进化成为程序猿也有段岁月了,所谓的经验,广度还是依旧,只不过是对于某种功能有了多种实现方式的想法.每天依旧不厌其烦的敲打着代码,每一行代码的回车似乎都有一种似曾相识的感觉.于是乎:粘贴复制,再粘贴再复 ...

  6. VS CODE 下的 ESLint 安装以及使用

    经过半年的前端磨练(就是不停地敲敲代码),自认水平提高的速度还是可以的. 现在回头看下写过的代码,发现以前写的代码真的是不忍惨睹. 比如 变量名乱起 风格多变 注释乱写或者没写 等等错误; 这不是一个 ...

  7. 深入理解jQuery中的Deferred

    引入 1  在开发的过程中,我们经常遇到某些耗时很长的javascript操作,并且伴随着大量的异步. 2  比如我们有一个ajax的操作,这个ajax从发出请求到接收响应需要5秒,在这5秒内我们可以 ...

  8. 对病毒Virus.Win32.Ramnit.B的研究

  9. Net分布式系统之三:Keepalived+LVS+Nginx负载均衡之高可用

    上一篇写了nginx负载均衡,此篇实现高可用(HA).系统整体设计是采用Nginx做负载均衡,若出现Nginx单机故障,则导致整个系统无法正常运行.针对系统架构设计的高可用要求,我们需要解决Nginx ...

  10. dma驱动

    http://www.crifan.com/files/doc/docbook/dma_pl08x_analysis/release/html/dma_pl08x_analysis.html#idp2 ...