Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.57 KB

File metadata and controls

56 lines (41 loc) · 1.57 KB

Task 1: Autocomplete System

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"]

Task 2: Word Search

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"]

Task 3: Implement a Dictionary for Spell Checking

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"]

Task 4: Longest Prefix Match

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"