Given a string input of length n, find the length of the longest substring without repeating characters i.e return a substring that does not have any repeating characters.
Substring is the continuous sub-part of the string formed by removing zero or more characters from both ends.
The first and the only line consists of a string of length n containing lowercase alphabets.
Output format:
You need to print the length of the longest unique characters substring.
1<= n <=10^5
Time Limit: 1 sec
abcabcbb
3
Substring "abc" has no repeating character with the length of 3.
aaaa
1
Think of creating all of the substrings.
O(N^3), where N is the length of the string.
We would be creating every substring, which takes N^2 time, and for checking whether it consists of unique characters, it will take N time.
O(N), where N is the length of the string.
Since we have used set for checking duplication in strings.