Implement Magic Dictionary

The canonical "Implement Magic Dictionary" problem supports building a dictionary and searching for a word that can become equal to some dictionary word by changing exactly one character (same length, exactly one substitution).

This repository uses a functional execution contract: solve(arg1) receives an array of strings and returns 1 or 0. Under the current fixture contract, arg1[0] is treated as the query word and the function returns 1 if any string in arg1 has the same length as the query and differs from it in exactly one character position; otherwise it returns 0.

An identical string has zero differences and does not satisfy "exactly one character changed".

Input: arg1 = ["hello","hhllo"]

Output: 1

hhllo differs from hello by exactly one character.

Input: arg1 = ["hello","hello"]

Output: 0

  • arg1 follows the functional execution schema
  • Strings consist of lowercase English letters unless otherwise specified by fixtures

Related Problems

  • implement-trie-prefix-tree

Companies Asked

  • Google
  • Amazon
  • Microsoft
  • Meta
  • Twitter
Examples
Input: ["hello","hhllo"]
Output: 1
Hints

Implement Magic Dictionary

The canonical "Implement Magic Dictionary" problem supports building a dictionary and searching for a word that can become equal to some dictionary word by changing **exactly one character** (same length, exactly one substitution).