A password strength meter rewards long runs of characters with no repeats. Given the typed text s, it looks for the longest slice of neighboring characters in which no character appears twice.
Write longestRepeatFree(s) that returns the length of that slice. Upper and lower case letters are different characters.
Input: s = "mapmaker" Output: 6
pmaker is the longest slice without a repeat.
Input: s = "kayak" Output: 3
kay and yak both work. Any longer slice repeats a letter.
0 <= s.length <= 100000s contains printable ASCII characters.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #142 Longest Repeat-Free Slice. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.