<awangdev>1048. Longest String Chain_1.java
public int longestStrChain(String[] words) {
        int rst = 0;
        Arrays.sort(words, Comparator.comparing(a -> a.length()));
        HashMap<String, Integer> wordChainMap = new HashMap();
        for (String word : words) {
            if (wordChainMap.containsKey(word)) continue;
            wordChainMap.put(word, 1);
            for (int i = 0; i < word.length(); i++) {
                StringBuilder sb = new StringBuilder(word);
                sb.deleteCharAt(i);
                String lastWord = sb.toString();
                if (wordChainMap.containsKey(lastWord) && wordChainMap.get(lastWord) + 1 > wordChainMap.get(word)) {
                    wordChainMap.put(word, wordChainMap.get(lastWord) + 1);
                }
            }
            if (wordChainMap.get(word) > rst) rst = wordChainMap.get(word);
        }
        return rst;
    }
public int sample_funcname ( String [ ] var_1 ) {
  int var_3 = 0 ;
  Arrays . sort ( var_1 , Comparator . comparing ( var_8 -> var_8 . length ( ) ) ) ;
  HashMap < String , Integer > var_12 = new HashMap ( ) ;
  for ( String var_13 : var_1 ) {
    if ( var_12 . containsKey ( var_13 ) ) continue ;
    var_12 . put ( var_13 , 1 ) ;
    for ( int var_17 = 0 ;
    var_17 < var_13 . length ( ) ;
    var_17 ++ ) {
      StringBuilder var_19 = new StringBuilder ( var_13 ) ;
      var_19 . deleteCharAt ( var_17 ) ;
      String var_22 = var_19 . toString ( ) ;
      if ( var_12 . containsKey ( var_22 ) && var_12 . get ( var_22 ) + 1 > var_12 . get ( var_13 ) ) {
        var_12 . put ( var_13 , var_12 . get ( var_22 ) + 1 ) ;
      }
    }
    if ( var_12 . get ( var_13 ) > var_3 ) var_3 = var_12 . get ( var_13 ) ;
  }
  return var_3 ;
}
