package leetcode;

/**
 * https://leetcode.com/problems/implement-magic-dictionary/
 */
public class Problem676 {
    static class MagicDictionary {

        /** Initialize your data structure here. */
        public MagicDictionary() {
            // TODO
        }

        /** Build a dictionary through a list of words */
        public void buildDict(String[] dict) {
            // TODO
        }

        /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */
        public boolean search(String word) {
            // TODO
            return false;
        }
    }

    public static void main(String[] args) {
        MagicDictionary dict = new MagicDictionary();
        dict.buildDict(new String[]{"hello", "leetcode"});
        dict.search("hello"); // false
        dict.search("hhllo"); // true
        dict.search("hell"); // false
        dict.search("leetcode"); // false
    }
}

@@ -141,16 +141,414 @@
 ionary %7B
+%0A        private static class Node %7B%0A            private char ch;%0A            private boolean end;%0A            private Node%5B%5D children = new Node%5B26%5D;%0A%0A            public Node(char ch) %7B%0A                this.ch = ch;%0A            %7D%0A%0A            @Override%0A            public String toString() %7B%0A                return %22%22 + ch;%0A            %7D%0A        %7D%0A%0A        private final Node root = new Node(' ');
 %0A%0A      
@@ -628,36 +628,16 @@
 ary() %7B%0A
-            // TODO%0A
         
@@ -748,39 +748,653 @@
 ) %7B%0A            
-// TODO
+for (String str : dict) %7B%0A                root.children%5Bstr.charAt(0) - 'a'%5D = build(str, 0, root);%0A            %7D%0A        %7D%0A%0A        private static Node build(String str, int idx, Node node) %7B%0A            if (idx == str.length()) %7B%0A                return null;%0A            %7D%0A            Node n = node.children%5Bstr.charAt(idx) - 'a'%5D;%0A            if (n == null) %7B%0A                n = new Node(str.charAt(idx));%0A                node.children%5Bstr.charAt(idx) - 'a'%5D = n;%0A            %7D%0A            Node m = build(str, idx + 1, n);%0A            if (m == null) %7B%0A                n.end = true;%0A            %7D%0A            return n;
 %0A        %7D%0A%0A    

Update problem 676