You are viewing a single comment's thread. Return to all comments →
Here is the code I was mentioning:
#!/bin/python3 import re from itertools import combinations s_len = int(input().strip()) s = input().strip() def isValid(s, a, b): regex1 = a + a regex2 = b + b regex3 = r"[^" + a + b + r"]+" if (re.search(regex1, s) or re.search(regex2, s) or re.search(regex3, s)): return False else: return True max = 0 for p in combinations(set(s), 2): s2 = "".join(x for x in s if x in p) if isValid(s2, p[0], p[1]): if len(s2) > max: max = len(s2) 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 →
Here is the code I was mentioning: