966. Vowel Spellchecker Medium

@problem@discussion
#Array#Hash Table#String



1/**
2 * [966] Vowel Spellchecker
3 *
4 * Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.
5 * For a given query word, the spell checker handles two categories of spelling mistakes:
6 * 
7 * 	Capitalization: If the query matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the case in the wordlist.
8 * 	
9 * 		Example: wordlist = ["yellow"], query = "YellOw": correct = "yellow"
10 * 		Example: wordlist = ["Yellow"], query = "yellow": correct = "Yellow"
11 * 		Example: wordlist = ["yellow"], query = "yellow": correct = "yellow"
12 * 	
13 * 	
14 * 	Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist.
15 * 	
16 * 		Example: wordlist = ["YellOw"], query = "yollow": correct = "YellOw"
17 * 		Example: wordlist = ["YellOw"], query = "yeellow": correct = "" (no match)
18 * 		Example: wordlist = ["YellOw"], query = "yllw": correct = "" (no match)
19 * 	
20 * 	
21 * 
22 * In addition, the spell checker operates under the following precedence rules:
23 * 
24 * 	When the query exactly matches a word in the wordlist (case-sensitive), you should return the same word back.
25 * 	When the query matches a word up to capitlization, you should return the first such match in the wordlist.
26 * 	When the query matches a word up to vowel errors, you should return the first such match in the wordlist.
27 * 	If the query has no matches in the wordlist, you should return the empty string.
28 * 
29 * Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].
30 *  
31 * Example 1:
32 * Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
33 * Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
34 * Example 2:
35 * Input: wordlist = ["yellow"], queries = ["YellOw"]
36 * Output: ["yellow"]
37 *  
38 * Constraints:
39 * 
40 * 	1 <= wordlist.length, queries.length <= 5000
41 * 	1 <= wordlist[i].length, queries[i].length <= 7
42 * 	wordlist[i] and queries[i] consist only of only English letters.
43 * 
44 */
45pub struct Solution {}
46
47// problem: https://leetcode.com/problems/vowel-spellchecker/
48// discuss: https://leetcode.com/problems/vowel-spellchecker/discuss/?currentPage=1&orderBy=most_votes&query=
49
50// submission codes start here
51
52impl Solution {
53    pub fn spellchecker(wordlist: Vec<String>, queries: Vec<String>) -> Vec<String> {
54        vec![]
55    }
56}
57
58// submission codes end
59
60#[cfg(test)]
61mod tests {
62    use super::*;
63
64    #[test]
65    fn test_966() {
66    }
67}
68


Back
© 2025 bowen.ge All Rights Reserved.