Java | Easy Solution | Set | Without Trie
\nclass MagicDictionary {\n\n    /** Initialize your data structure here. */\n    Set<String> set;\n    public MagicDictionary() {\n        set=new HashSet<>();
```\nclass MagicDictionary {\n\n    /** Initialize your data structure here. */\n    Set<String> set;\n    public MagicDictionary() {\n        set=new HashSet<>();\n    }\n    \n    public void buildDict(String[] dictionary) {\n        for(String s:dictionary) set.add(s);\n    }\n    \n    public boolean search(String searchWord) {\n        for(String s:set){\n          if(canMake(s,searchWord)) return true;\n        }\n      return false;\n    }\n   public boolean canMake(String s,String sw){\n     if(s.length()!=sw.length()) return false;\n     int count=0;\n     for(int i=0;i<s.length();i++){\n       if(s.charAt(i)!=sw.charAt(i)) count++;\n       if(count>1) return false;\n     }\n     return count==1;\n   }\n}\n\n/**\n * Your MagicDictionary object will be instantiated and called as such:\n * MagicDictionary obj = new MagicDictionary();\n * obj.buildDict(dictionary);\n * boolean param_2 = obj.search(searchWord);\n */\n```
[]