美文网首页
Leetcode 3

Leetcode 3

作者: 若柏 | 来源:发表于2018-01-13 16:11 被阅读0次

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

解题思路:遍历时将字符串中出现过的字符以哈希表的方式存储,并加入判断条件:若字符已位于哈希表且当前最大字符串的起始位置不大于该字符在哈希表中存储的值,则更新起始位置为该值+1。maxlength为历史最大字符串与当前最大字符串的最大值。

相关文章

网友评论

      本文标题:Leetcode 3

      本文链接:https://www.haomeiwen.com/subject/zmbcoxtx.html