Leaderboard
Showing:
Length of the longest substring
Medium Accuracy: 36.38% Submissions: 209 Points: 4

Given a string S, find the length of the longest substring without repeating characters.


Example 1:

Input:
S = "geeksforgeeks"
Output:
7
Explanation:
Longest substring is
"eksforg".

Example 2:

Input:
S = "ABDEFGABEF"
Output:
6
Explanation:
Longest substring is
"BDEFGA" and "DEFGAB".

 

Your Task:
You don't need to take input or print anything. Your task is to complete the function longestUniqueSubsttr() which takes a string S as and returns the length of the longest substring.

 

Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).


Constraints:
1 ≤ |S| ≤ 104

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Length of the longest substring

Output Window