Find longest substring without repeating characters

前端 未结 30 2558
轻奢々
轻奢々 2020-12-12 18:07

Given a string S of length N find longest substring without repeating characters.

Example:

Input:

30条回答
  •  一个人的身影
    2020-12-12 19:10

    Tested and working. For easy understanding, I suppose there's a drawer to put the letters.

    Function:

    
        public int lengthOfLongestSubstring(String s) {
            int maxlen = 0;
            int start = 0;
            int end = 0;
            HashSet drawer = new HashSet(); 
            for (int i=0; imaxlen) {
                        maxlen=_maxlen;
                    }
                }
            }
            return maxlen;
        }
    

提交回复
热议问题