Problem:
Design an autocomplete system for a search engine or messaging app that suggests possible completions based on the user’s input. The system should be able to return a list of suggestions quickly as the user types.
Input:
- A list of words:
["apple", "appetizer", "application", "banana", "band", "bandit"] - User input:
"app"
Output:
- List of suggestions:
["apple", "appetizer", "application"]
Problem:
Given a 2D board of characters and a list of words, return all the words from the list that can be formed by a sequence of adjacent characters in the grid (horizontally or vertically).
Input:
- Board:
['o', 'a', 'a', 'n'], ['e', 't', 'a', 'e'], ['i', 'h', 'k', 'r'], ['i', 'f', 'l', 'v'] ]``` - List of words:
["oath", "pea", "eat", "rain"]
Output:
- List of found words:
["oath", "eat"]
Problem:
Implement a spell checker that uses a dictionary to identify and correct spelling errors. Given a list of words, suggest possible corrections for a misspelled word by checking the closest matches in the dictionary.
Input:
- Dictionary:
["hello", "hell", "world", "help"] - Misspelled word:
"helo"
Output:
- Suggested corrections:
["hello", "hell"]
Problem:
Given a list of words, find the longest common prefix among all of them.
Input:
- List of words:
["flower", "flow", "flight"]
Output:
- Longest common prefix:
"fl"