code: static boolean[] terminalHydrogens(final IAtomContainer ac, final int[][] g) {
  
          final boolean[] hydrogens = new boolean[ac.getAtomCount()];
  
          // we specifically don't check for null atomic number, this must be set.
          // if not, something major is wrong
          for (int i = 0; i < ac.getAtomCount(); i++) {
              IAtom atom = ac.getAtom(i);
              hydrogens[i] = atom.getAtomicNumber() == 1 &&
                             atom.getMassNumber() == null &&
                             g[i].length == 1;
          }
  
          return hydrogens;
      }
docs: Locate explicit hydrogens that are attached to exactly one other atom.
  
  @param ac a structure
  @return binary set of terminal hydrogens