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. C++设计模式-Strategy策略模式

    Strategy策略模式作用:定义了算法家族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化,不会影响到使用算法的客户. UML图: Strategy模式将逻辑(算法)封装到一个类(Cont ...

  2. ebs如何将客户化的PL/SQL程序发布到webservice

    as:cux_gl_hec_iface_soa_pkg. 1.将package声明部分的内容拷贝出来另存为cux_gl_hec_iface_soa_pkg.pls的文件: 2.将该文件上传到服务器上拥 ...

  3. java.lang.classnotfoundexception org.json.jsonexception

    java.lang.classnotfoundexception org.json.jsonexception 解决方法 http://www.java2s.com/Code/Jar/j/Downlo ...

  4. linux系统的常用命令

    linux系统中常用的命令如下(以后经常补充): cd ..   返回上一级 cd use  进入use目录

  5. Maximo子表中增加附件功能

    附件功能的实现(详见ewell.webclient.beans.warranty.WarrantysDateBean ,ewell.webclient.beans.doclinks.custom.Ad ...

  6. gb2312

    ---恢复内容开始--- 字符集 gb2312(字全)采用2两个字节(一个汉字) utf-8(只有汉字)采用3个字节(一个汉字) html就是负责描述页面的语义:css负责描述页面的样式:js负责描述 ...

  7. css左右居中的几种常见方法

    本人是前端的新人,这是第一次写技术博客,各位大大,本文有错误请指正,手中的板砖尽量轻拍,我怕疼~~ 对于水平居中和垂直居中我也用过很多方法,但是有的时候管用有的时候又嗝屁不好使了.涉及到的情况很多,所 ...

  8. PPP(杜撰)

    最开始,电话线入户,用户买来电脑想上网,最简便的方法想办法利用电话线来实现. 最后想了个法子,用电脑的UART的口连到电话线上: 网络提供商一段也用UART为用户提供网络服务: 那么问题来了,UART ...

  9. Kafka报错-as it has seen zxid 0x83808 our last zxid is 0x0 client must try another server

    as it has seen zxid 0x83808 our last zxid is 0x0 client must try another server 停止zookeeper,删除datadi ...

  10. 关于shape_trans (ConnectedRegions, ConvexRegions, 'convex')的作用于对比

    * crystal.hdev: extraction of hexagonally shaped crystals via local thresholding and region post-pro ...