Company: Goldman_Sachs__
Difficulty: medium
1. Question 1 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. Examples Example 1: Input: s = "abcbbck" Explanation: To make the string contain only distinct characters, we need to remove characters that cause duplicates. A possible resulting string with distinct characters is "abck". To achieve "abck" from "abcbbck", we can remove: 1. The substring "bbc" (from index 3 to 5). The remaining parts are "abc" + "k", which forms "abck". Length of removed substring = 3. 2. The substring "cbb" (from index 2 to 4). The remaining parts are "ab" + "ck", which forms "abck". Length of removed substring = 3. The problem asks for the shortest substring to delete. Bot