3207. Make Three Strings Equal
My accepted Python solution to LeetCode problem 3207, Make Three Strings Equal, running in 3ms.
- Difficulty: Easy
- Python
- Runtime 3ms
- Memory 17.5MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 3ms, memory 17.5MB, accepted 2025-12-29.
class Solution:
def findMinimumOperations(self, s1: str, s2: str, s3: str) -> int:
min_len = min(len(s1), len(s2), len(s3))
prefix_len = 0
for i in range(min_len):
if s1[i] == s2[i] == s3[i]:
prefix_len += 1
else:
break
if prefix_len == 0:
return -1
return (len(s1) - prefix_len) + (len(s2) - prefix_len) + (len(s3) - prefix_len)