You are viewing a single comment's thread. Return to all comments →
Required a bit a thinking, perhaps should have been a medium question.
Here is my Python3 solution (i'm sure it may be tougher in other languages)
from itertools import combinations _, s = input(), input() max = 0 s_set = set(s) length = len(s_set) if length > 1: for c in combinations(s_set,length-2): new_s = s for ch in c: new_s = new_s.replace(ch,'') if len([i for i in range(len(new_s)-1) if new_s[i] == new_s[i+1]]) == 0: if len(new_s) > max: max = len(new_s) print(max)
Seems like cookies are disabled on this browser, please enable them to open this website
Two Characters
You are viewing a single comment's thread. Return to all comments →
Required a bit a thinking, perhaps should have been a medium question.
Here is my Python3 solution (i'm sure it may be tougher in other languages)