# LeetCode: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.

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class  Solution { public :      int  lengthOfLongestSubstring(string s) {          vector< int > bitmap(128, -1);          int  res = 0;          int  start = 0, lastStart = 0;          for ( int  i = 0; i < s.size(); i++)          {              if (bitmap[s[i]] != -1)              {                  res = max(res, i-start);                  lastStart = start;                  start = bitmap[s[i]] + 1;                  for ( int  j = lastStart; j < bitmap[s[i]]; j++)                      bitmap[s[j]] = -1;              }              bitmap[s[i]] = i;          }          res = max(res, ( int )s.size()-start); //不要忘了最后的判断          return  res;      } };

|
10月前
Leetcode 516. Longest Palindromic Subsequence

37 0
|
10月前
|
Java
Leetcode 3. Longest Substring Without Repeating Characters

41 3
|

LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
109 0
LeetCode 424. Longest Repeating Character Replacem

97 0
LeetCode 409. Longest Palindrome

67 0
|
1月前
|
Python
【Leetcode刷题Python】剑指 Offer 32 - III. 从上到下打印二叉树 III

37 6
|
1月前
|
Python
【Leetcode刷题Python】剑指 Offer 26. 树的子结构

33 4
|
1月前
|

【Leetcode刷题Python】牛客. 数组中未出现的最小正整数

63 2
|
1月前
|

【Leetcode刷题Python】从列表list中创建一颗二叉树

31 7
|
1月前
|
Python
【Leetcode刷题Python】剑指 Offer 30. 包含min函数的栈

16 4

DDNS