private boolean isValid(char[] cs) {

    HashSet<Character> set = new HashSet<Character>();
    for (char ch : cs) {
      if (!set.contains(ch)) {
        set.add(ch);
      } else {
        if (ch != '.') {
          return false;
        }
      }
    }
    return true;
  }