Java - beats 100% - No HashMap/Trie - Easy to understand
This solution doesn\'t use HashMap or Trie. \nbuildDict(String[] dict) complexity is O(1). \nsearch(String word) complexity is O(NK) where N is the total number
This solution doesn\'t use HashMap or Trie. \n```buildDict(String[] dict)``` complexity is O(1). \n```search(String word)``` complexity is O(NK) where N is the total number of words in dictionary and K is the length of word to be searched.\n\n\n```\nclass MagicDictionary {\n\n    String[] dictionary;\n    /** Initialize your data structure here. */\n    public MagicDictionary() {\n        \n    }\n    \n    /** Build a dictionary through a list of words */\n    public void buildDict(String[] dict) {\n        dictionary = dict;\n    }\n    \n    /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */\n    public boolean search(String word) {\n        for (String dictWord: dictionary) {\n            if (dictWord.length() == word.length()) {\n                int count = 0;\n                for (int i=0; i< word.length(); i++) {\n                    if (word.charAt(i) != dictWord.charAt(i)) {\n                        count++;\n                    }\n                    if (count > 1) {\n                        break;\n                    }\n                }\n                if (count == 1) {\n                    return true;\n                }\n            }\n        }\n        return false;\n    }\n}\n```
[]