583. Delete Operation for Two Strings Medium
1/**
2 * [583] Delete Operation for Two Strings
3 *
4 * Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.
5 * In one step, you can delete exactly one character in either string.
6 *
7 * Example 1:
8 *
9 * Input: word1 = "sea", word2 = "eat"
10 * Output: 2
11 * Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
12 *
13 * Example 2:
14 *
15 * Input: word1 = "leetcode", word2 = "etco"
16 * Output: 4
17 *
18 *
19 * Constraints:
20 *
21 * 1 <= word1.length, word2.length <= 500
22 * word1 and word2 consist of only lowercase English letters.
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/delete-operation-for-two-strings/
28// discuss: https://leetcode.com/problems/delete-operation-for-two-strings/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn min_distance(word1: String, word2: String) -> i32 {
34 0
35 }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_583() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.