首页 > 代码库 > Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

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.

答案

public class Solution {
    public int lengthOfLongestSubstring(String s) {
        int result=0;
        Map<Character,Integer> map=new HashMap<Character,Integer>(500);
        int start;
        int end;
        for(start=0,end=0;end<s.length();end++)
        {
            Integer value=http://www.mamicode.com/map.get(s.charAt(end));>

Longest Substring Without Repeating Characters