Company: trading tech_17sep
Difficulty: medium
Minimal Substring Split Problem Description You are given a string S of length N made of lowercase English letters. Cut S into consecutive, non-empty pieces (substrings) that, read from left to right, join back up to exactly S . Inside every piece, no letter may appear more than once . Find the minimum number of pieces such a split can have. A string whose letters are already all different needs no cut at all, and the answer is then 1 . For example, S = abacdec can be split as a | bac | dec , as a | bacd | ec or as ab | ac | dec . Each of these uses 3 pieces, and no split into fewer pieces is valid. Complete the function solution , which takes the string S and returns the minimum number of pieces. Input Format Read from standard input. S The only line contains the string S . (inferred -- the source gives only the function signature; the string alone on one line is the input layout used here.) Output Format Print a single integer: the minimum number of pieces. Constraints 1 <= N <