Given a string s consisting only lower case alphabets, find the minimum number of changes required to it so that all substrings of the string become distinct.
Note: length of the string is at most 26.
Example 1:
Input: S = "aab"
Output: 1
Explanation: If we change one instance
of 'a' to any character from 'c' to 'z',
we get all distinct substrings.
​Example 2:
Input: S = "ab" Output: 0 Explanation: As no change is required hence 0.
Your Task:
You don't need to read input or print anything. Your task is to complete the function minChange() which takes the string S as inputs and returns the answer.
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(26)
Constraints:
1 ≤ |S| ≤ 26