DIY: Longest Substring without Repeating Characters
Solve the interview question "Longest Substring without Repeating Characters" in this lesson.
We'll cover the following
Problem statement
In this coding example, you are given a string str
. Your task is to find the longest substring without repeating characters. You also have to return the length of this longest substring.
Note: If a DNA sequence is empty (does not have any chromosomes), you will return its length, which will be
0
.
Input
The input should be a string. The following are examples of input to the function:
// Sample Input 1:
"abcabcbb"
// Sample Input 2:
""
Output
The output should be a pair of a string and an integer that represents the longest substring without any repeating characters and its length respectively. The following are examples of outputs:
// Sample Output 1:
("abc", 3)
// Sample Output 2:
("", 0)
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.