Problem:
 Score : 200 points    Problem Statement You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y .
Here, we would like to maximize the number of different letters contained in both X and Y .
Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.      Constraints  2 \leq N \leq 100  |S| = N  S consists of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  S       Output Print the largest possible number of different letters contained in both X and Y .        Sample Input 1 6
aabbca      Sample Output 1 2  If we cut the string between the third and fourth letters into X =  aab and Y =  bca , the letters contained in both X and Y are a and b .
There will never be three or more different letters contained in both X and Y , so the answer is 2 .       Sample Input 2 10
aaaaaaaaaa      Sample Output 2 1  However we divide S , only a will be contained in both X and Y .       Sample Input 3 45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir      Sample Output 3 9

Solution (Python):
n=int(input())
s=input()

ans=0

for i in range(0,n-1):
    s1=set([])
    s2=set([])
    for j in range(0,i+1):
        s1.add(s[j])
    for j in range(i+1,n):
        s2.add(s[j])
    
    s1=s1.intersection(s2)
    ans=max(ans,len(s1))

print(ans)

Solution (Python):
def main():
    N = int(input())
    S = input()

    maxn = 0
    for i in range(1, N):
        x, y = set(S[:i]), set(S[i:])
        maxn = max(maxn, len(x & y))
    print(maxn)

main()

Solution (Python):
N = int(input())
S = list(input())
max = 0
for i in range(1,N):
    A = S[:i]
    B = S[i:]
    intersection = len(set(A) & set(B))
    if max < intersection:
        max = intersection
print(max)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    A = set(list(s[:i]))
    B = set(list(s[i:]))
    current = list(A & B)
    
    if len(current) > ans:
        ans = len(current)
        
print(ans)

Solution (Python):
n = int(input())
s = input()
maxnum = 0
for i in range(1,n):
    num = 0
    s1 = set(s[0:i])
    s2 = set(s[i::])
    for c in s1:
        if c in s2:
            num += 1
    if maxnum < num:
        maxnum = num
print(maxnum)

Solution (Python):
N = list(map(int, input().split()))
S = input()
result = 0
maxnum = len(set(S))
for i in range(len(S)):
    X = set(S[:i])
    Y = set(S[i:])
    Z = X & Y
    if result < len(Z):
        result = len(Z)
    if result == maxnum:
        break

print(result)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
  s1 = s[:i]
  s2 = s[i:]
  lst = []
  for k in s1:
    if k in s2:
      lst.append(k)
  ans = max(ans, len(list(set(lst))))

print(ans)

Solution (Python):
n = int(input())
s = input()

result = 0

for i in range(n):
    a = s[:i]
    b = s[i:]
    result = max(result, len(set(a) & set(b)))

print(result)

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline()
    result = 0
    for i in range(1, N):
        s1 = S[:i]
        s2 = S[i:]
        result = max(result, len(set(s1) & set(s2)))
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = list(input())

ans = 0
for i in range(1,n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    count = 0
    for sc in s1:
        if sc in s2:
            count += 1
    ans = max(ans, count)
print(ans)

Solution (Python):
n = int(input())
s = input()
num = 0
for i in range(len(s)):
    t1 = s[:i]
    t2 = s[i:]
    rec = 0
    rec1 = []
    for j in range(len(s)):
        if s[j] in t1 and s[j] in t2 and s[j] not in rec1:
            rec += 1
            rec1.append(s[j])

    num = max(num, rec)
print(num)

Solution (Python):
N = int(input())
S = input()

max_s = 0
for i in range(1, N):
    X = set(S[:i])
    Y = set(S[i:])
    if len(X & Y) > max_s:
        max_s = len(X & Y)
print(max_s)

Solution (Python):
def main():
    n = int(input())
    s = input()

    r = []
    for i in range(n):
        ls = set(list(s[0:i+1]))
        rs = set(list(s[i+1:]))
        r.append(len(ls.intersection(rs)))
    print(max(r))

main()

Solution (Python):
N = int(raw_input())
S = raw_input()

score_list = []
for i in range(N):
	score_list.append(len(set(S[:i])&set(S[i:])))

print max(score_list)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = s[:i]
    b = s[i:]
    c = []
    count = 0
    for j in a:
        if j in b and j not in c:
            count += 1
            c.append(j)
            ans = max(ans,count)
print(ans)

Solution (Python):
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    x, y = s[:i], s[i:]
    setX = set()
    setY = set()
    for a in x:
        setX.add(a)
    for b in y:
        setY.add(b)
    z = setX & setY
    ans = max(ans, len(z))

print(ans)

Solution (Python):
N = int(input())
S = list(input())
out = []
for i in range(N):
    dic = {}
    for j in range(N):
        if (j <= i):
            dic[S[j]] = 0
        else:
            if S[j] in dic:
                dic[S[j]] = 1
        a = 0
        for it in dic.values():
            a+=it
        out.append(a)

print(max(out))

Solution (Python):
N = int(input())
S = input()
maximum = 0

for i in range(1, N):
    S1 = set(S[:i])
    S2 = set(S[i:])
    count = len(S1 & S2)
    if maximum < count:
        maximum = count

print(maximum)

Solution (Python):
N = int(input())
s = input()
d = 0
for i in range(N):
    a = set(s[:i])
    b = set(s[i:])
    c = len(a.intersection(b))
    if c >= d:
        d = c
print(d)

Solution (Python):
N = int(input())
s = input()

print(max([len(set(s[:n]).intersection(s[n:])) for n in range(1, N)]))

Solution (Python):
n = int(input())
s = input()

ans = 0

for i in range(1, n):
  x = set(s[:i])
  y = set(s[i:])
  
  ans = max(ans, len(x&y))
print(ans)

Solution (Python):
N = int(raw_input())
S = raw_input()

ans = 0
for i in range(N):
    count = 0
    s1 = S[:i]
    s2 = S[i:]
    s1 = list(s1)
    s1 = list(set(s1))
    for j in range(len(s1)):
        if s2.find(s1[j]) > -1:
            count += 1
    ans = max(ans, count)

print(ans)

Solution (Python):

N = int(input())

S = list(input())

A = 0
for i in range(N):
    X = S[:i]
    Y = S[i:]
    b = len(set(X) & set(Y))
    A = max(A,b)
print(A)

Solution (Python):
n = int(input())
s = list(input())

commons_len = 0

for i in range(n):
    left = set(s[:i])
    right = set(s[i:])
    commons_len = max(len(left.intersection(right)),commons_len)

print(commons_len)

Solution (Python):
N = int(input())
S = input()

ma = 0
for i in range(N):
    X = set(S[:i])
    Y = set(S[i:])
    Z = X & Y
    ma = max(ma, len(Z))

print(ma)

Solution (Python):
n = int(input())
S = input()
ans = 0
for i in range(1, n):
    x = set(S[:i])
    y = set(S[i:])
    ans = max(ans, len(x.intersection(y)))
print(ans)

Solution (Python):
n = int(input())
st = input()
l = []
for i in range(n+1):
    l.append(len(set(st[:i]) & set(st[i:])))
print(max(l))

Solution (Python):
N = int(input())
S = input()
Ans = 0
for i in range(N):
    s1 = set(list(S[0:i+1]))
    s2 = set(list(S[i+1:N]))
    Ans = max(Ans,len(s1&s2))
print(Ans)

Solution (Python):
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
S = input()
ret = 0

for i in range(1, len(S)):
  a, b = S[:i], S[i:]
  ret = max(ret, len(set(a) & set(b)))
print(ret)

Solution (Python):
n = int(input())
s = input()
m = 0
for i in range(n):
    x = s[:i]
    y = s[i:]
    m = max(m, len(set(x) & set(y)))
print(m)

Solution (Python):
n = int(input())
s = list(input())
ans = 0

for i in range(1, n):
  a, b = s[:i], s[i:]
  temp = set(a) & set(b)
  ans = max(ans, len(temp))

print(ans)

Solution (Python):
n = int(input())
s = input()

ans = 0

for i in range(len(s)):
  ans = max(ans, len(set(s[:i]) & set(s[i:])))

print(ans)

Solution (Python):
def main():
    N = int(input())
    S = input()

    ans = 0
    for i in range(N):
        s = set(S[:i]) & set(S[i:])
        ans = max(ans, len(s))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
res = 0
for i in range(N):
    S_A = set(S[:i])
    S_B = set(S[i:])
    res = max(res, len(S_A & S_B))
print(res)

Solution (Python):
n = int(input())
s = input()

res = 0
for i in range(n):
    tmp_res = 0
    tmp1 = set(s[:i])
    tmp2 = set(s[i:])
    for j in tmp2:
        if j in tmp1:
            tmp_res += 1
    if tmp_res > res:
        res = tmp_res
print(res)