Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Hey there, young coder! Are you ready for a fun challenge that will help you learn how to work with strings in Python? Today, we're going to look at finding the longest substring within a string that has no repeating characters!
Imagine you have a string, and you want to find the maximum length of a substring where no characters repeat. A substring is simply a part of the string; like how 'cat' is a substring of 'caterpillar'.
Here's a quick example to help you understand:
longest_substring("abcdefg")
Output:
7
Here, the whole string 'abcdefg' is a substring with no repeating characters.
Another example:
longest_substring("aacbdb")
Output:
3
In this case, both 'acb' and 'bdb' are substrings with no repeating characters, and each is 3 characters long. So, the function returns 3!
Are you ready to make your mark and create the function that solves this puzzle? Let's go!
Good luck, and have fun coding!
Inputs
Arg 1:
"abcabcbb"Expected Output
3Actual Output