Smallest distinct window
Medium Accuracy: 50.29% Submissions: 16314 Points: 4

Given a string 's'. The task is to find the smallest window length that contains all the characters of the given string at least one time.
For eg. A = “aabcbcdbca”, then the result would be 4 as of the smallest window will be “dbca”.


Example 1:

Output : 3
Explanation : Sub-string -> "BAC"
Example 2:
Input : "aaab"
Output : 2
Explanation : Sub-string -> "ab"
Example 3:
Output : 8
Explanation : Sub-string -> "GEEKSFOR"


Your Task:  
You don't need to read input or print anything. Your task is to complete the function findSubString() which takes the string  S as inputs and returns the length of the smallest such string.

Expected Time Complexity: O(256.N)
Expected Auxiliary Space: O(256)


1 ≤ |S| ≤ 105
String may contain both type of English Alphabets.

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.

Smallest distinct window

Output Window