524. Longest Word in Dictionary through Deleting Medium

@problem@discussion
#Array#Two Pointers#String#Sorting



1/**
2 * [524] Longest Word in Dictionary through Deleting
3 *
4 * Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.
5 *  
6 * Example 1:
7 * 
8 * Input: s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]
9 * Output: "apple"
10 * 
11 * Example 2:
12 * 
13 * Input: s = "abpcplea", dictionary = ["a","b","c"]
14 * Output: "a"
15 * 
16 *  
17 * Constraints:
18 * 
19 * 	1 <= s.length <= 1000
20 * 	1 <= dictionary.length <= 1000
21 * 	1 <= dictionary[i].length <= 1000
22 * 	s and dictionary[i] consist of lowercase English letters.
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/
28// discuss: https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn find_longest_word(s: String, dictionary: Vec<String>) -> String {
34        String::new()
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_524() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.