#2937

Make Three Strings Equal

easy · 44.7% accepted · 322 likes · top 27%

string

⊣ practice⊣ open on leetcode ↗

Description

You are given three strings: s1, s2, and s3. In one operation you can choose one of these strings and delete its rightmost character. Note that you cannot completely empty a string.

Return the minimum number of operations required to make the strings equal. If it is impossible to make them equal, return -1.

Solution