Coding Task: Maximize Different Letters in Split Strings
Problem Statement
You are given a string ( S ) of length ( N ) consisting of lowercase English letters. Your task is to determine the optimal position to cut this string into two parts, ( X ) and ( Y ), such that the total number of different letters contained in both ( X ) and ( Y ) is maximized.
Objective
Find the maximum number of distinct letters contained in both substrings ( X ) and ( Y ) when the string ( S ) is split at the optimal position.
Input Format
A single string ( S ) where ( 1 \leq |S| \leq 100,000 ) (length of string ( S )).
The string ( S ) contains only lowercase English letters.
Output Format
Output a single integer which represents the maximum number of different letters that can be found in both ( X ) and ( Y ).
Example
Input
text
abracadabra
Output
text
5
Explanation
Possible splits of the string could yield different unique letters in ( X ) and ( Y ). In this case, if we split after the first 'a' (e.g. ( X = "a" ) and ( Y = "bracadabra" )), we can find 5 unique letters: 'a', 'b', 'c', 'd', 'r'.
Implementation
Please implement the solution in the /app/ directory of your project.
Important: place your implementation at /app/solution.py so the verifier can run it.