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(1,n):
    left=set(s[:i])
    right=set(s[i:])
    cnt=0
    for j in left:
        if j in right:
            cnt+=1
    ans=max(ans,cnt)
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  l = set(S[:i]); r = set(S[i:]);
  ans = max(ans, len(l & r))
print(ans)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  l = list(set(S[:i])); r = list(set(S[i:]));
  cnt = 0
  for s in l:
    cnt += r.count(s)
  ans = max(ans, cnt)
print(ans)

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

    ans = 0
    for i in range(1,n-1):
        l = S[:i]
        r = S[i:]
        ans = max(ans, len(set(l) &set(r)))
    print(ans)


if __name__ == '__main__':
    main()

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

max_common_char = 0
for idx in range(N):
    p, v = S[:idx], S[idx:]
    commons = len(set(list(p)) & set(list(v)))
    if max_common_char <= commons:
        max_common_char = commons
print(max_common_char)

Solution (Python):
N=int(input())
s=list(input())
ans = 0
for i in range(N):
    tmp = len(set(s[:i])&set(s[i:]))
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
import sys
import os
import re
import datetime

N = int(input())
S = input()

maxCount = 0
for i in range(1, len(S) - 1):
	sl = S[:i] 
	sr = S[i:] 
	
	setl = set(sl)
	setr = set(sr)
	setAnd = setl & setr
	
	maxCount = max(len(setAnd), maxCount)

print(maxCount)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    s = input()

    if n == 2:
        if s[0] == s[1]:
            print(1)
            exit()
        else:
            print(0)
            exit()

    ans = 0
    for i in range(1, n):
        front = set(s[0:i])
        back = set(s[i:n])

        tmp = len(front.intersection(back))
        if ans < tmp:
            ans = tmp

    print(ans)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    s = input()

    if n == 2:
        if s[0] == s[1]:
            print(1)
            exit()
        else:
            print(0)
            exit()

    ans = 0
    for i in range(1, n):
        front = set(s[0:i])
        back = set(s[i:n])

        tmp = 0
        for f in front:
            if f in back:
                tmp += 1
        if ans < tmp:
            ans = tmp

    print(ans)

Solution (Python):








def resolve():

    n=int(input())
    s=str(input())

    print(max(len(set(s[:i])&set(s[i:])) for i in range(n)))

resolve()

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(n):
    sf=set(s[:i])
    sl=set(s[i:])
    ans=max(len(sf&sl),ans)
print(ans)

Solution (Python):
def count(s1,s2):
    st1,st2=set([c for c in s1]),set([c for c in s2])
    return len(st1&st2)

N=int(input())
S=input()
print(max([count(S[:i],S[i:]) for i in range(N)]))

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

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

ans = 0

for i in range(1,N-1):
    left = set(S[:i])
    right = set(S[i:])
    ans = max(ans,len(list(left&right)))

print(ans)

Solution (Python):
N=int(input())
S=input()
ans=0
 
for i in range(N):
    A=S[:i]
    B=S[i:]
    sum=0
    l=[]
    for j in A:
        if (j in B) and (j not in l):
            sum+=1
            l.append(j)
    ans=max(sum,ans)
print(ans)

Solution (Python):
N=int(input())
S=input()
ans = 0
for i in range(1,N-1):
  X = [0] * 26
  cnt = 0
  for x in range(i):
    X[ord(S[x])-ord('a')] = 1
  for y in range(i,N):
    if ( X[ord(S[y])-ord('a')] == 1 ):
      cnt += 1
      X[ord(S[y])-ord('a')] = 0
  ans = max(ans,cnt)
print(ans)

Solution (Python):
a = int(input())
c = list(input())
ans = 0
for i in range(1,a):
  b = c[:]
  h = len(set(b[:i]) & set(b[i:]))
  if h > ans:
    ans = h
print(ans)

Solution (Python):
n=int(input())
a=[ord(i)-97 for i in input()]
maxx=0
for i in range(n):
    st1=set(a[:i])
    st2=set(a[i:])
    maxx=max(maxx,len(st1&st2))
print(maxx)

Solution (Python):

n = int(input())
s = input()
l = [0] * n
for i in range(n-1):
    count = 0
    a = s[:i+1]
    b = s[i+1:]
    
    for j in set(a):
        if j in set(b):
            count += 1
    
    l[i] = count
    
print(max(l))

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

max_set = 0
for i in range(1, N+1):
    front = set(S[:i])
    back = set(S[i:])
    tmp_set = len(front & back)
    if tmp_set > max_set:
        max_set = tmp_set

print(max_set)

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

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

print(ans)

Solution (Python):
n = int(input())
s = input()
ans = []

for i in range(n-1):
    left = set(s[:i+1])
    right = set(s[i+1:])
    cnt = 0
    for j in left:
        if j in right:
            cnt += 1
    ans.append(cnt)

print(max(ans))

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

ans = [0] * (n - 1)
cnt = 0
for i in range(n - 1):
    s_1 = set(s[:i + 1])
    s_2 = list(set(s[i + 1:]))

    for j in s_1:
        if j in s_2:
            cnt += 1

    ans[i] = cnt
    cnt = 0

print(max(ans))

Solution (Python):
N=int(input())
S=input()
res=0
for i in range(1,len(S)):
    t=set(S[:i])
    m=set(S[i:])
    res=max(res,len(t.intersection(m)))
print(res)

Solution (Python):
import string

n = int(input())
strs = input()

ans = 0

for i in range(n):
    left = strs[:i]
    right = strs[i:]
    score = 0
    for a in string.ascii_lowercase:
        if a in left and a in right:
            score += 1
    
    if score > ans:
        ans = score
    
print(ans)

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

ans = 0
for i in range(n-1):
  x = s[:i+1]
  y = s[i+1:]
  count = 0
  
  for j in range(len(x)):
    if (x[j] in y) and not(x[j] in x[:j]) :
      count += 1
  
  
  if ans < count:
    ans = count
  

print(ans)

Solution (Python):

n=int(input())
s=input()
print(max([len(set(s[:i])&set(s[i:])) for i in range(1,n)]))

Solution (Python):


N = int(input().strip())
S = input().strip()


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

print(ans)

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

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

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

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

print(ans)

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

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

Solution (Python):
N = int(input())
S = list(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(input())
s = input()
S = []
for i in s:
    S.append(i
    )

ans = 0
for i in range(1, n):
    x = S[0:i]
    y = S[i:n]
    a = 0
    for j in range(len(x)):
        if x[j] in y:
            a += 1
            while x[j] in y:
                y[y.index(x[j])] = 0
    ans = max(ans, a)
print(ans)

Solution (Python):
n=int(input())
s=list(input())
ans = 0
for i in range(1,n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  ans = max(ans, len(s1&s2))
print(ans)

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(N):
    X=list(S[:i])
    Y=list(S[i:])
    ans=max(ans,len(set(X)&set(Y)))
    
print(ans)

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

ans = 0

for i in range(1,n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    cnt = 0
    for j in range(len(x)):
        for k in range(len(y)):
            if x[j] ==  y[k]:
                cnt += 1

    ans = max(cnt ,ans)

print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
  s1 = set(s[:i])
  s2 = set(s[i:])
  ans = max(ans, len(s1&s2))
print(ans)

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

for i in range(n):
    a=set(s[:i])
    b=set(s[i:])
    c=list(a & b)
    l=max(len(c),l)
print(l)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    X = S[0 : i]
    Y = S[i : N]
    X_and_Y_li = list(set(X) & set(Y))
    if len(X_and_Y_li) > ans :
        ans = len(X_and_Y_li)
print(ans)

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

count = 0
for i in range(1, n):
    temp = set()
    for j in range(i):
        if s[j] in set(s[i:]):
            temp.add(s[j])
    count = max(len(temp), count)

print(count)

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

count = 0
for i in range(1, n):
    temp = set()
    for j in range(i):
        if s[j] in s[i:]:
            temp.add(s[j])
    count = max(len(temp), count)

print(count)

Solution (Python):
n = int(input())
s = input()
result = []
for i in range(1, n):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    result.append(len(a & b))
print(max(result))

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
s = input()

a = []

for i in range(n+1):
    a.append(len(set(s[:i]) & set(s[i:])))
print(max(a))

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(N):
  X,Y = S[:i],S[i:]
  tmp=len(set(list(X)) & set(list(Y)))
  if tmp>ans:
    ans=tmp
print(ans)

Solution (Python):
n = int(input())
s = input()
most= 0
for i in range(1,n):
    count = 0
    x = set(s[i:])
    y = set(s[:i])
    for j in x:
        if j in y:
            count += 1
        if count > most:
            most = count
print(most)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
for i in range(N):
    l = set(S[:i])
    r = set(S[i:])
    S_intersection = l & r
    ans = max(len(S_intersection), ans)
print(ans)

Solution (Python):
N=int(input())
S=str(input())
ans=0
for i in range(1,N):
    X=set(S[:i])
    Y=set(S[i:])
    X&=Y
    ans=max(ans,len(X))
print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
    buf=0
    for j in range(97,97+26):
        if chr(j) in s[:i] and chr(j) in s[i:]:
            buf+=1
    if buf>ans:
        ans=buf
print(ans)

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict, Counter

n = ni()
s = ns()

ans = 0
for i in range(n - 1):
    d = defaultdict(int)
    b = defaultdict(int)
    cnt = 0
    for j in range(i + 1):
        d[s[j]] += 1
    for j in range(i + 1, n):
        b[s[j]] += 1
    for k, j in d.items():
        if b[k] >= 1:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Solution (Python):
n = int(input())
s = list(input())
x = 0
for i in range(n):
    S1 = set(s[:i])
    S2 = set(s[i:])
    S1 &= S2
    if len(S1) >= x:
        x = len(S1)
print(x)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=STR()
    ct=0
    for i in range(n):
        seta=set(s[0:i])
        setb=set(s[i:])
        ct=max(ct,len(seta&setb))
    print(ct)
if __name__ == '__main__':
    do()

Solution (Python):
N = int(input())
S = list(input())
 
m = 0
for i in range(1, N - 1):
    a = set(S[:i])
    b = set(S[i:])
    if m < len(a & b):
        m = len(a & b)
 
print(m)

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

ans= 0
for i in range(1,N):
    set1 = set()
    set2 = set()
    
    for s in S[:i]:
        set1.add(s)
    for s in S[i:]:
        set2.add(s)
    
    sets = set1 & set2
    ans = max(ans,len(list(sets)))

print(ans)

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

ans = 0

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

Solution (Python):
n = int(input())
s = input()
l = []
for i in range(1, n):
    cnt = 0
    for j in set(s[:i]):
        if j in list(s[i:]):
            cnt += 1
    l.append(cnt)
print(max(l))

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

m = 0
for i in range(1, N - 1):
    a = set(S[:i])
    b = set(S[i:])
    if m < len(a & b):
        m = len(a & b)

print(m)

Solution (Python):
N = int(input())
S = input()
answer = 0
for i in range(1, N):
    
    x = list(set(S[:i]))
    y = list(set(S[i:]))
    
    
    count = 0
    for j in range(len(x)):
        if x[j] in y:
            count += 1
    if answer <= count:
        answer = count

print(answer)

Solution (Python):
n = int(input())
s = input()
ans = 0
for i in range(1, n-1):
  ans = max(ans, len(set(s[:i])&set(s[i:])))
print(ans)

Solution (Python):
n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    left = set(s[0:i])
    right = set(s[i:n])
    ans = max(ans, len(left & right))
print(ans)

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

s = input()
t = 0
m = 0
for i in range(n):
    a = s[:i]
    b = s[i:]
    A = list(set(a))
    B = list(set(b))
    for i in A:
        if i in B:
            t += 1
    if m < t:
        m = t
    t = 0
print(m)

Solution (Python):
N = int(input())
S = input()
m = 0
for i in range(1, N):
    l = set(S[:i])
    r = set(S[i:])
    both = l & r
    if len(both) > m:
        m = len(both)

print(m)

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

ans = 0
for i in range(n):
    cnt = 0
    for j in set(s[:i]):
        if j in set(s[i:]):
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Solution (Python):
n = int(input())
s = input()
maxi = 0
for i in range(n):
  left  = s[:i+1]
  right = s[i+1:]
  left = set(list(left))
  right = set(list(right))
  cnt = len(left & right)
  if maxi < cnt:
    maxi = cnt
print(maxi)

Solution (Python):
n=int(input())
s=str(input())
ans=0
for i in range(n-1):
    a=set(s[i+1:])
    b=set(s[:i+1])
    ans=max(ans,len((a&b)))
print(ans)

Solution (Python):
N=int(input())
S=list(input())
import copy
A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
L=[[0 for i in range(26)]]
for i in range(N):
    l=copy.deepcopy(L[-1])
    for j in range(26):
        if S[i]==A[j]:
            l[j]+=1
    L.append(l)

ans=0
for i in range(N):
    cnt=0
    for j in range(26):
        if L[i][j]>0 and L[-1][j]-L[i][j]>0:
            cnt+=1
    if ans<cnt:
        ans=cnt
print(ans)

Solution (Python):
n = int(input())
s = input()
lis = []

for i in range(1, n):
  a = set(s[:i])
  b = set(s[i:])
  count = 0
  for c in a:
    if c in b:
      count += 1
  lis.append(count)
print(max(lis))

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(1,N):
  X=set(S[i:])
  Y=set(S[:i])
  ans=len(X & Y) if ans<len(X & Y) else ans
print(ans)

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

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

ans=0
for i in range(N):
    X=S[:i]
    Y=S[i:]
    temp=0
    for j in range(26):
        if chr(ord("a")+j) in X and chr(ord("a")+j) in Y:
            temp+=1
    ans=max(ans,temp)
print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
    A=set(s[:i])
    B=set(s[i:])
    cnt=0
    for a in A:
        if a in B:cnt+=1
    ans=max(cnt,ans)
print(ans)

Solution (Python):
import numpy as np
input()
S = input()
X = np.zeros((26, ), dtype=np.int64)
Y = np.zeros((26, ), dtype=np.int64)

for c in S:
    Y[ord(c) - ord("a")] += 1

ans = 0
for c in S:
    X[ord(c) - ord("a")] += 1
    Y[ord(c) - ord("a")] -= 1
    ans = max(ans, (X.astype(bool) * Y.astype(bool)).sum())

print(ans)

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(1,N):
    l,r=set(S[:i]),set(S[i:])
    if ans<len(l&r):
        ans=len(l&r)
print(ans)

Solution (Python):
n = int(input())
s = input()
alph = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

cnt = 0
for i in range(n):
    prev = s[:i]
    subseq = s[i:]
    inner_cnt = 0
    for j in alph:
        if j in prev and j in subseq:
            inner_cnt += 1
    if inner_cnt > cnt:
        cnt = inner_cnt
print(cnt)

Solution (Python):
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def check(s, idx):
    s1 = set(s[:idx])
    s2 = set(s[idx:])

    return len(s1 & s2)

def main():
    n = int(input())
    s = input()[:-1]

    ma = -1 * 10**9
    
    for i in range(1, n):
        c = check(s, i)
        if c > ma:
            ma = c

    print(ma)
    return

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter


def main():
    N = int(input())
    S = input()
    answer = 0
    for i in range(1, N):
        first_half = Counter(S[:i])
        second_hald = Counter(S[i:])
        answer = max(answer, len(first_half & second_hald))
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = input()
sn = len(set(s))
r = 0
for i in range(n+1):
    t = len(set(s[:i])) + len(set(s[i:])) - sn
    r = r if r>t else t
print(r)

Solution (Python):




def main():
    N = int(input())
    S = input()
    result = []
    for i in range(N + 1):
        result.append(len(set(S[:i]) & set(S[i:])))
    print(max(result))


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(N-1):
	F=set(S[:i+1])
	G=set(S[i+1:])
	ans=max(ans,len(F&G))
print(ans)

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

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

Solution (Python):


n = int(input())
s = list(input())

l = []
for i in range(1, n):
    a = s[0:i]
    b = s[i:]
    x = []
    for j in range(len(a)):
        if a[j] in b:
            x.append(a[j])
    else:
        l.append(len(set(x)))

print(max(l))

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


l = []
for i in range(1, n):
    a = s[0:i]
    b = s[i:]

    x = []
    for j in range(len(a)):
        if a[j] in b:
            x.append(a[j])
    else:
        l.append(len(set(x)))
print(max(l))

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

cnt = []

for l in range(1, len(S)):
    cnt.append(len(set(S[:l]) & set(S[l:])))
    
print(max(cnt))

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

arr = []

for i in range(1,n):
    l = set(s[:i])
    r = set(s[i:])
    arr.append(len(l & r))

print(max(arr))

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

Solution (Python):
n = int(input())
s = list(str(input()))
ans = 0
for i in range(n-1):
    l = s[:i+1]
    r = s[i+1:]
    t = len(set(l) & set(r))
    ans = max(t, ans)

print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
  s1=s[:i]
  s2=s[i:]
  li1=set([s1[j] for j in range(len(s1))])
  li2=set([s2[j] for j in range(len(s2))])
  ans = max(ans,len(li1 & li2))
print(ans)

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

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

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

ans = 0
for i in range(1, n - 1):
  count = 0
  a = s[:i]
  b = s[i:]
  c = set()
  for j in a:
    if b.count(j) >= 1 and not j in c:
      count += 1
      c.add(j)
  ans = max(ans, count)

print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,len(s)):
    left=s[:i]
    right=s[i:]
    l=len(set(left)&set(right))
    ans=max(l,ans)
print(ans)

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

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

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

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

max=0
count=0

for i in range(1,len(s)):
    str1=set(list(s[0:i]))
    str2=set(list(s[i:n]))
    for c in str1:
        if c in str2:
            count+=1
            if max<=count:
                max=count
    count=0

print(max)

Solution (Python):
import collections
N=int(input())
S=input()
count=0
for i in range(1,N):
  A=S[:i]
  B=S[i:]
  a=collections.Counter([j for j in A if j in B])
  if count<len(a):
    count=len(a)
print(count)

Solution (Python):
n,s,c=int(input()),list(input()),0
for i in range(n):
  h=len(set(s[:i])&set(s[i:]))
  c=max(c,h)
print(c)

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

for i in range(1, n):
    x = s[:i]
    y = s[i:]
    cnt = 0
    for j in range(i):
        if(y.count(x[j])):
            y = y.replace(x[j], '')
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Solution (Python):
n=int(input())
s=input()
moji=[0]*26
for i in range(n):
    moji[ord(s[i])-97]+=1
ans=0
for rightcut in range(n):
    k=0
    temp=moji[:]
    for i in range(rightcut):
        if temp[ord(s[i])-97]>0:
            temp[ord(s[i])-97]-=1
    for j in range(26):
        k+=1 if (temp[j]!=0 and temp[j]!=moji[j] ) else 0
    ans = k if k>ans else ans
print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
for i in range(1,n):
  x=s[:i]
  y=s[i:]
  cnt=0
  for j in range(i):
    if y.count(x[j]):
      y=y.replace(x[j],'')
      cnt+=1
  ans = max(ans, cnt)
print(ans)

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

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(N):
    X = dict()
    Y = dict()
    p = []
    count = 0
    for j in range(N):
        if j <= i:
            if S[j] in X:
                X[S[j]] += 1
            else:
                X[S[j]] = 0
        else:
            if S[j] in Y:
                Y[S[j]] += 1
            else:
                Y[S[j]] = 0
        if S[j] in X and S[j] in Y:
            if S[j] not in p:
                count += 1
                p.append(S[j])
    ans = max(ans,count)
print(ans)

Solution (Python):
import sys

n=int(input())
s=str(input())
list=[]
for i in range(1,n):
	a=s[0:i]
	b=s[i:]
	count=0
	for j in range(97,97+26):
		if (chr(j) in a)and(chr(j) in b):
			count+=1
	list.append(count)
print(max(list))

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

ans = 0
for i in range(n):
  cnt = 0
  for c in ss:
    if c in s[:i] and c in s[i:]:
      cnt += 1
  ans = max(ans, cnt)

print(ans)

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

apls = list(set(n))
count = 0

for i in range(1, s+1):
    tmp = 0
    for apl in apls:
        if n[:i].count(apl) != 0 and n[i:].count(apl) != 0:
            tmp += 1
    if count < tmp:
        count = tmp

print(count)

Solution (Python):
N= int(input())
S = list(input())
count=0
saidai=0
for i in range(1, N-1):
    count = len(set(S[:i]) & set(S[i:]))
    saidai=max(saidai, count) 
print(saidai)

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

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

Solution (Python):
import collections

N = int(input())
S = input()

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

print(m)

Solution (Python):
import collections

N = int(input())
S = input()

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    
    common_char = a & b
    if len(common_char) > m:
        m = len(common_char)
        index = i
print(m)

Solution (Python):
import collections

N = int(input())
S = input()

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    d = 0
    for c in a:
        if c in b:
            d += 1
    if d > m:
        m = d
        index = i
print(m)

Solution (Python):
from collections import Counter

def solve(n, s):
    c = Counter(s)
    ret, tmp = 0, 0
    d = set()
    for l in s:
        c[l] -= 1
        if c[l] == 0:
            tmp -= 1

        if l not in d:
            tmp += 1
        d.add(l)

        if ret < tmp:
            ret = tmp
    return ret

_n = int(input())
_s = input()
print(solve(_n, _s))

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

print(max(len(set(S[:i]) & set(S[i:])) for i in range(N)))

Solution (Python):
def solve():
    N = int(input())
    S = input()
    max_spieces = 0
    for i in range(1, N):
        pre = set(S[:i])
        post = set(S[i:])
        intersection_num = len(pre&post)
        if intersection_num > max_spieces:
            max_spieces = intersection_num
            
    print(max_spieces)
    
solve()

Solution (Python):
n = int(input())
l = list(input())
ans = 0
for i in range(n):
    count = len(set(l[:i])&set(l[i:]))
    ans = max(count,ans)
print(ans)

Solution (Python):
n = int(input())
l = list(input())
ans = 0
for i in range(n):
  l1 = l[i+1:]
  
  count = set()
  for j in range(i+1):
    if l[j] in l1:
      count.add(l[j])
  ans = max(ans,len(count))
  
print(ans)

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

mx=0

for i in range(1,N):
    str1=S[i:]
    str2=S[:i]

    same=[]

    for c1 in str1:
        for c2 in str2:
            if c1==c2:
                same.append(c1)

    if mx < len(set(same)):
        mx= len(set(same))

print(mx)

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    num = 0
    for j in range(i):
        if s[j] not in s[:j] and s[j] in s[i:]: num += 1
    if num > ans: ans = num
print(ans)

Solution (Python):

import sys 

n = int(input())
s = input()

def comp(str1, str2):
    s1 = set(list(str1))
    s2 = list(str2)
    ans = 0 
    for i in s1: 
        if i in s2: 
            ans += 1
    return ans 

ans = 0 
for i in range(n-1):
   ls = s[:i+1]
   rs = s[i+1:]
   tmp = comp(ls, rs) 
   ans = max(ans, tmp)

print(ans)

Solution (Python):




n = int(input())
s = input()

clist_d = [[0] * 27 for i in range(len(s) + 1)]

for i in range(len(s)):
    idx = ord(s[i]) - 97
    clist_d[i][idx] = clist_d[i][idx] + 1

    for j in range(26):
        clist_d[i+1][j] = clist_d[i][j]

maxcnt = 0
for i in range(len(s)):
    cnt = 0
    for j in range(26):
        if clist_d[i][j] > 0 and clist_d[i][j] < clist_d[len(s)-1][j]:
            cnt = cnt + 1
        
        if maxcnt < cnt:
            maxcnt = cnt
    
ans = maxcnt


print(ans)

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

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

Solution (Python):
import string
n = int (input())
s = input()
az = string.ascii_lowercase

ans = []

for i in range(1,n):
     count = 0
     before = s[:i]
     after = s[i:]
     for j in az:
         if j in before and j in after:
              count +=1
     ans.append(count)
print(max(ans))

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

for i in range(1, n, 1):
    a = s[:i]
    b = s[i:]
    rep = 0
    for word in "abcdefghijklmnopqrstuvwxyz":
        if word in a and word in b:
            rep += 1
    ans = max(ans, rep)
print(ans)

Solution (Python):
from collections import Counter
n=int(input())
s=input()

count=0
max_count=0
for i in range(1,n):
    x=s[:i]
    y=s[i:]
    l=Counter(x)
    t=Counter(y)
    for j in l.keys():
        if(j in t.keys()):
            count+=1
    if(max_count < count):
        max_count=count
    count=0
print(max_count)

Solution (Python):
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = list(readline().decode('utf8').rstrip())

ans = 0
for i in range(1, len(S)):
    X = set(S[:i])
    Y = set(S[i:])
    n = len(X & Y)
    ans = max(n, ans)

print(ans)

Solution (Python):
a = input()
b = raw_input()
x = 0
for i in range(1,a):
    z = b[0:i]
    y = b[i:a]
    arr = []
    for l in y:
        for m in z:
            if l == m and l not in arr:
                arr.append(l)
    if len(arr) > x:
        x = len(arr)
print x

Solution (Python):
N=int(input())
S=input()
ans=0
for i in range(N):
  A=set(S[:i])
  B=set(S[i:])
  cnt=0
  for j in A:
    if (j in B):
      cnt+=1
  ans=max(ans,cnt)
print(ans)

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

Solution (Python):
n = int(input())
s = input()
count_list = []
for i in range(1, 99):
    x, y = set(s[:i]), set(s[i:])
    count = len(x&y)
    count_list.append(count)
print(max(count_list))

Solution (Python):
n = input()
s = raw_input()
ans = 0
for i in range(1,n):
    a = s[0:i]
    b = s[i:n]
    arr = []
    for l in a:
        for m in b:
            if l == m and l not in arr:
                arr.append(l)
    if len(arr) > ans:
        ans = len(arr)
print ans

Solution (Python):
n=int(input())
s=input()
l=[0 for i in range(26)]
for c in s:
    l[ord(c)-ord('a')]+=1
r=[0 for i in range(26)]
ans=0

for c in s:
    l[ord(c)-ord('a')]-=1
    r[ord(c)-ord('a')]+=1
    tmp=0
    for i in range(26):
        if l[i] and r[i]:
            tmp+=1
    if ans<tmp:
        ans=tmp
print(ans)

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

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

for i in range(N):
    s = set(S[:i]).intersection(set(S[i:]))
    ans = max(ans, len(s))

print(ans)

Solution (Python):
a = int(input())
s = input()
max_str = 0
for i in range(2, a):
  b = set(s[:i]) & set(s[i:])
  max_str = max(max_str, len(b))
print(max_str)

Solution (Python):
n=int(input())
s=list(input())
ans=0
for i in range(1,n):
  ans=max(ans,len(set(s[:i])&set(s[i:])))
print(ans)