树相关

前缀树

class Tries {
        Boolean isEnd;
        Tries[] children;

        Tries(Boolean isEnd) {
            children = new Tries[26];
            this.isEnd = isEnd;
        }
    }

    public void insertNode(String str, Tries head) {
        if (str == null || str.length() == 0)
            return;
        char chs[] = str.toCharArray();
        int i = chs.length - 1;
        Tries cur = head;
        while (i >= 0) {
            if (cur.children[chs[i] - 'a'] == null) {
                cur.children[chs[i] - 'a'] = new Tries(false);
            }
            cur = cur.children[chs[i] - 'a'];
            i--;
        }
        cur.isEnd = true;
    }