Company: Goldman Sachs_22july
Difficulty: medium
Find Shortest Substring Problem Description Determine the length of the shortest substring to delete from a string s of length n , so that the resulting string contains only distinct characters. A substring is a sequence of characters that appear consecutively within a string. If a substring is deleted, the remaining parts of the string are joined together. If no deletion is necessary, the answer should be 0. Complete the function findShortestSubstring in the editor with the following parameter: s : the string to analyze Returns: int : an integer representing the length of the shortest substring that should be deleted Examples Example 1: Input: s = "abcbkck" Output: 3 Explanation: There are three optimal choices: "abcbkck", "abcbkck", and "abcbkck". The bold characters are the substrings to remove. All result in "abck" which has only distinct characters. The removed substring must have at least 3 characters. Example 2: Input: s = "xabbcacpqr" Output: 3 Explanation: Given string s = "xa