DAYS
HOUR
MINS
SEC
Error
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:
Input : "AABBBCBBAC"
Output : 3
Explanation : Sub-string -> "BAC"
Input : "aaab"
Output : 2
Explanation : Sub-string -> "ab"
Input : "GEEKSGEEKSFOR"
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 input and returns the length of the smallest such window of the string.
Expected Time Complexity: O(256.N)
Expected Auxiliary Space: O(256)
Constraints:
1 ≤ |S| ≤ 105
String may contain both type of English Alphabets.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes