DIY: Longest Substring without Repeating Characters

Solve the interview question "Longest Substring without Repeating Characters" in this lesson.

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.


The input should be a string. The following are examples of input to the function:

// Sample Input 1:

// Sample Input 2:


The output should be a tuple that contains the longest substring without any repeating characters and its length. The following are examples of outputs:

// Sample Output 1:
("abc", 3)

// Sample Output 2:
(null, 0)

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.