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 int lengthOfLongestSubstring(String s) {
int max_len = 1;
for(int i=0; i<s.length(); i++) {
for(int j=i+

该博客探讨了如何解决LeetCode中的‘最长无重复字符子串’问题。通过给出的例子‘abcabcbb’和‘bbbbb’,解释了目标是找到字符串中最长的不包含重复字符的子串及其长度。博主提到初步尝试的遍历方法会导致超时,并指出问题可能在于使用`lastIndexOf`导致效率低下。
订阅专栏 解锁全文
687

被折叠的 条评论
为什么被折叠?



