Leetcode Problem 966. Vowel Spellchecker

966. Vowel Spellchecker

Leetcode Solutions

HashMap-based Spellchecker

  1. Initialize three hashmaps: exact, lowercase, and vowelless.
  2. For each word in wordlist, add it to the exact hashmap.
  3. Convert each word to lowercase and add it to the lowercase hashmap if it's not already present, to store the first occurrence.
  4. Convert each word to its vowelless form (replace all vowels with a special character) and add it to the vowelless hashmap if it's not already present.
  5. For each query in queries, check for an exact match in the exact hashmap.
  6. If no exact match is found, check for a case-insensitive match in the lowercase hashmap.
  7. If no case-insensitive match is found, convert the query to its vowelless form and check for a match in the vowelless hashmap.
  8. If no match is found in any hashmap, return an empty string for that query.
  9. Return the list of corrected words for all queries.
UML Thumbnail

Brute Force Spellchecker

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...