void addWord(String s, Set<String> set) {
        if (!set.add(s))
            return;
        char[] a = s.toCharArray();
        TrieNode x = root;
        for (int i = a.length - 1; i >= 0; i--) {
            TrieNode child = x.children[a[i] - 'a'];
            if (child == null) {
                child = new TrieNode(a[i]);
            } else {
                if (child.isWord && child.count > 0)
                    res -= i + 1;
                child.count++;
            }
            if (i == 0 && !child.isWord) {
                if (child.count == 0)
                    res += a.length + 1;
                child.isWord = true;
            }
            x.children[a[i] - 'a'] = child;
            x = child;
        }
    }
Why Did you create this class? what does it do?
src/problems/medium/ShortEncodingofWords.java