2025-08-22 11:19:56 +0000 UTC
Make Three Strings Equal
Categories:
Links
Code
class Solution:
def findMinimumOperations(self, s1: str, s2: str, s3: str) -> int:
n1, n2, n3 = len(s1), len(s2), len(s3)
for i in range(max(n1, n2, n3)):
fail = True
if i < n1 and i < n2 and i < n3:
c1, c2, c3 = s1[i], s2[i], s3[i]
if c1 == c2 and c2 == c3:
fail = False
if not fail:
continue
if i == 0:
return -1
return max(n1 - i, 0) + max(n2 - i, 0) + max(n3 - i, 0)
return 0