public String shortestMatch(String input){
  TrieNode node=root;
  for (int i=input.length() - 1; i >= 0; i--) {
    node=node.getChild(input.charAt(i));
    if (node == null)     return null;
    if (node.isTerminal())     return input.substring(i);
  }
  return null;
}

public String shortestMatch ( String input ) { TrieNode node = root ; for ( int i = input . length ( ) - 1 ; i >= 0 ; i -- ) { node = node . getChild ( input . charAt ( i ) ) ; if ( node == null ) return null ; if ( node . isTerminal ( ) ) return input . substring ( i ) ; } return null ; }
returns the shortest suffix of < code > input < code > that is matched , or < code > null < code > if no match exists .
