Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.

解决方法(java版)

class Solution{
    public int lengthOfLongestSubstring(String s) {
        String str=new String();
        str="";
        int max=0;
        for(int i=0;i<s.length();i++){
         for(int j=i;j<s.length();j++){
          if(str.contains(String.valueOf(s.charAt(j)))){
           break;
          }
          else{
           str+=s.charAt(j);
          }
           }
  if(str.length()>max)
    max=str.length();
  str="";
       }
        return max;
    }
}

leetcode:Longest Substring Without Repeating Characters的更多相关文章

  1. C++版- Leetcode 3. Longest Substring Without Repeating Characters解题报告

    Leetcode 3. Longest Substring Without Repeating Characters 提交网址: https://leetcode.com/problems/longe ...

  2. Leetcode经典试题:Longest Substring Without Repeating Characters解析

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

  3. LeetCode OJ:Longest Substring Without Repeating Characters(最长无重复字符子串)

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

  4. LeetCode第[3]题(Java):Longest Substring Without Repeating Characters 标签:Linked List

    题目中文:没有重复字符的最长子串 题目难度:Medium 题目内容: Given a string, find the length of the longest substring without ...

  5. leetcode笔记:Longest Substring Without Repeating Characters

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

  6. No.003:Longest Substring Without Repeating Characters

    问题: Given a string, find the length of the longest substring without repeating characters.Example:Gi ...

  7. LeetCode 3 Longest Substring Without Repeating Characters(最长不重复子序列)

    题目来源:https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, f ...

  8. LeetCode 3 Longest Substring Without Repeating Characters 解题报告

    LeetCode 第3题3 Longest Substring Without Repeating Characters 首先我们看题目要求: Given a string, find the len ...

  9. Leetcode 3. Longest Substring Without Repeating Characters (Medium)

    Description Given a string, find the length of the longest substring without repeating characters. E ...

随机推荐

  1. Echarts - js

    <script type="text/javascript"> var myChart; myChart = echarts.init(document.getElem ...

  2. 常用WinPE

    微PE工具箱:http://www.wepe.com.cn/ 绝对PE工具箱:http://dl.pconline.com.cn/download/64736.html 通用PE工具箱:http:// ...

  3. Android eclipse中程序调试

    一:断点调试 用eclipse开发android程序的时,跟VS一样是可以断点单步调试的.步骤如下.1 设置断点:在编码窗体的左边框上用鼠标双击,或者右键点击菜单,选择 Toggle Breakpoi ...

  4. OpenMp并行提升时间为什么不是线性的?

    最近在研究OpenMp,写了一段代码,如下: #include<time.h> #include<stdio.h> #include<stdlib.h> #incl ...

  5. Android HTTPS(3) IOException: Hostname 解决方案

    Common Problems with Hostname Verification As mentioned at the beginning of this article, there are ...

  6. bigtint;int;smallint;tinyint

    bigint对应的是Int64     [long] int对应的是Int32          [int] smallint对应的是Int16  [short] tinyint对应的是  [byte ...

  7. getHitRect获取点击控件的位置

    public  void getHitRect(Rect outRect)                   Added in API level 1 Hit rectangle in parent ...

  8. 使用tdcss.js轻松制作自己的style guide

    http://jakobloekke.github.io/tdcss.js/ 在前端开发中,如果能够有一个style guide对于设计来说就显得专业稳定,一致性.在上述链接中,有一个tdcss.js ...

  9. 【笨嘴拙舌WINDOWS】实践检验之屏幕取色

    实践是检验真理的唯一标准 要取得屏幕的颜色,首先需要创建一个屏幕DC,然后使用该DC,调用GetPixel就可以了 "Note:GetPixel传入的DC应该是屏幕的DC,而不是桌面的DC, ...

  10. 51nod1421 最大MOD值

    O(n2)tle.O(nlognlogn) #include<cstdio> #include<cstring> #include<cctype> #include ...