CompetitiveProgramming/src/bin/test.py

11 lines
268 B
Python
Raw Normal View History

2024-04-04 10:33:48 +01:00
def diff(a, b):
n = len(a)
res = 0
for i in range(n):
if a[i] != b[i]:
for j in range(i + 1, n):
if b[j] == a[i]:
res += j - i
b = b[:i] + b[j] + b[i+1:j] + b[j+1:]
return res