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. Nodejs创建客户端

    Node 创建 Web 客户端需要引入 http 模块,创建 client.js 文件,代码如下所示: var http = require('http'); //用于请求的选项 var option ...

  2. LR12.53—第5课:创建负载测试场景

    在前面的课程中,您使用VuGen将验证您的Vuser脚本.在本课中,您将评估多个Vuser的负载下您的系统.您将模拟十个旅行代理同时使用航班预订系统的行动,以及这些用户的负载下观察系统的行为.设计和运 ...

  3. JQuery lhgdialog使用

    jQuery方式调用 J ); testDG4.SetPosition( 'center', 'center' );}; var testDG4 = J('#btn26').dialog({ id:' ...

  4. java 静态代码块 构造块 构造方法

    class className{ static{ }//静态代码块 { }//构造代码块 public className(){} //构造方法 }

  5. HBase的伪分布式安装(原创)

    准备工作: 1)安装了伪分布式hadoop:参照http://blog.csdn.net/zolalad/article/details/11472207 2)修改已安装好的hadoop配置文件: a ...

  6. 4中map遍历的方法

    public static void main(String[] args) { Map<String, String> map = new HashMap<String, Stri ...

  7. Winform 委托窗体传值

    有窗体Form1和窗体Form2,单击Form1按钮弹出Form2,单击Form2吧Form2的textBox控件文本传给Form1的label控件. 窗体1里: 实例化Form2,注册Form2的事 ...

  8. Linux 驱动学习笔记05--字符驱动实例,实现一个共享内存设备的驱动

    断断续续学驱动,好不容易有空,做了段字符驱动的例子.主要还是跟书上学习在此记录下来,以后说不定能回过头来温故知新. 首先上驱动源码 gmem.c: /************************* ...

  9. 【转】解决IIS7该问.svc文件的错误问题

        解决IIS7.5中部署WCF时,访问.svc文件的404错误问题如果你直接在IIS 7中配置WCF,访问.svc文件时会出现404错误.解决方法,以管理员身份进入命令行模式,运行:" ...

  10. iOS 类的判断方法

    -(BOOL) isKindOfClass: classObj 用来判断是否是某个类或其子类的实例 -(BOOL) isMemberOfClass: classObj 用来判断是否是某个类的实例 -( ...