Java Solution, easy understand
public class WordDictionary {\n        \n        Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();\n        // Adds a word into the data st
    public class WordDictionary {\n        \n        Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();\n        // Adds a word into the data structure.\n        public void addWord(String word) {\n            int index = word.length();\n            if(!map.containsKey(index)){\n                List<String> list = new ArrayList<String>();\n                list.add(word);\n                map.put(index, list);\n            }else{\n                map.get(index).add(word);\n            }\n            \n        }\n    \n        // Returns if the word is in the data structure. A word could\n        // contain the dot character '.' to represent any one letter.\n        public boolean search(String word) {\n            int index = word.length();\n            if(!map.containsKey(index)){\n                return false;\n            }\n            List<String> list = map.get(index);\n            if(isWords(word)){\n                return list.contains(word);\n            }\n            for(String s : list){\n                if(isSame(s, word)){\n                    return true;\n                }\n            }\n            return false;\n        }\n        \n        boolean isWords(String s){\n            for(int i = 0; i < s.length(); i++){\n                if(!Character.isLetter(s.charAt(i))){\n                    return false;\n                }\n            }\n            return true;\n        }\n        \n        boolean isSame(String a, String search){\n            if(a.length() != search.length()){\n                return false;\n            }\n            for(int i = 0; i < a.length(); i++){\n                if(search.charAt(i) != '.' && search.charAt(i) != a.charAt(i)){\n                    return false;\n                }\n            }\n            return true;\n        }\n    }
['Java']