feat(cses): a few problems

This commit is contained in:
Barrett Ruth 2025-02-21 11:26:06 -05:00
parent 3985e732d4
commit 4f0c2d75c5
65 changed files with 1197 additions and 35 deletions

17
kattis/18-2-2025/j.py Normal file
View file

@ -0,0 +1,17 @@
s = input()
n = len(s)
last_occurrence = {}
total = 0
for right in range(n):
char = s[right]
left = last_occurrence.get(char, -1) + 1
unique_chars = set()
for l in range(right - 1, left - 1, -1):
if s[l] not in unique_chars:
total += 1
unique_chars.add(s[l])
last_occurrence[char] = right
print(total)