2937. Make Three Strings Equal Easy

@problem@discussion
#String



1/**
2 * [2937] Make Three Strings Equal
3 *
4 * 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.
5 * Return the minimum number of operations required to make the strings equal. If it is impossible to make them equal, return -1.
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
9 * Input: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">s1 = "abc", s2 = "abb", s3 = "ab"</span>
10 * Output: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">2</span>
11 * Explanation: Deleting the rightmost character from both s1 and s2 will result in three equal strings.
12 * </div>
13 * <strong class="example">Example 2:
14 * <div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
15 * Input: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">s1 = "dac", s2 = "bac", s3 = "cac"</span>
16 * Output: <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">-1</span>
17 * Explanation: Since the first letters of s1 and s2 differ, they cannot be made equal.
18 * </div>
19 *  
20 * Constraints:
21 * 
22 * 	1 <= s1.length, s2.length, s3.length <= 100
23 * 	<font face="monospace">s1,</font> <font face="monospace">s2</font><font face="monospace"> and</font> <font face="monospace">s3</font> consist only of lowercase English letters.
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/make-three-strings-equal/
29// discuss: https://leetcode.com/problems/make-three-strings-equal/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn find_minimum_operations(s1: String, s2: String, s3: String) -> i32 {
35        0
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_2937() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.