feat(cses): a few problems
This commit is contained in:
parent
3985e732d4
commit
4f0c2d75c5
65 changed files with 1197 additions and 35 deletions
17
kattis/18-2-2025/j.py
Normal file
17
kattis/18-2-2025/j.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue