public ValidWordAbbr(String[] dictionary) {
            if (dictionary == null) return;

            for (String word : dictionary) {
                String abbr = compress(word);
                if (map.containsKey(abbr)) {
                    // use null to denote a duplicate
                    if (!word.equals(map.get(abbr))) map.put(abbr, null);
                } else {
                    map.put(abbr, word);
                }
            }
        }