We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difficulty: 中等
Related Topics: 哈希表, 字符串, 滑动窗口
给定一个字符串 s ,请你找出其中不含有重复字符的 **最长子串 **的长度。
s
示例 1:
输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
示例 2:
输入: s = "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
示例 3:
输入: s = "pwwkew" 输出: 3 解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。 请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。
提示:
Language: JavaScript
/** * @param {string} s * @return {number} */ var lengthOfLongestSubstring = function(s) { const set = new Set() let [l, r, maxLen] = [0, 0, 0] while(r < s.length) { set.has(s[r]) ? set.delete(s[l++]) : set.add(s[r++]) maxLen = Math.max(maxLen, set.size) } return maxLen }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
3. 无重复字符的最长子串
Description
Difficulty: 中等
Related Topics: 哈希表, 字符串, 滑动窗口
给定一个字符串
s
,请你找出其中不含有重复字符的 **最长子串 **的长度。示例 1:
示例 2:
示例 3:
提示:
s
由英文字母、数字、符号和空格组成Solution
Language: JavaScript
The text was updated successfully, but these errors were encountered: