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
No description provided.
The text was updated successfully, but these errors were encountered:
for循环大法
function getLongestRepeatString(s) { if (!s) return s; let ans = ''; const map = new Set(); for (let i = 0; i < s.length; i++) { for (let j = i + 1; j <= s.length; j++) { const chs = s.substring(i, j); if (map.has(chs) && chs.length > ans.length) { ans = chs; } map.add(chs); } } return ans; } console.log('abcbcabc =>', getLongestRepeatString('abcbcabc')); // abcbcabc => abc console.log('abcabcacbd =>', getLongestRepeatString('abcabcacbd')); // abcabcacbd => abca
Sorry, something went wrong.
function getMaxLengthChdStr (str) { let right = 0 let left = 0 const set = new Set() while (right < str.length) { if (set.has(str[right])) { set.delete(str[right]) left++ } else { set.add(str[right]) right++ } } return right - left } console.log(getMaxLengthChdStr('abcdaccc'))
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: