<qiyuangong>692_Top_K_Frequent_Words_1.java
public List<String> topKFrequent(String[] words, int k) {
        Map<String, Integer> count = new HashMap();
        for (String word: words) {
            count.put(word, count.getOrDefault(word, 0) + 1);
        }
        List<String> candidates = new ArrayList(count.keySet());
        Collections.sort(candidates, (w1, w2) -> count.get(w1).equals(count.get(w2)) ?
                w1.compareTo(w2) : count.get(w2) - count.get(w1));

        return candidates.subList(0, k);
    }
public List < String > var_1 ( String [ ] var_2 , int var_3 ) {
  Map < String , Integer > var_7 = new HashMap ( ) ;
  for ( String var_8 : var_2 ) {
    var_7 . put ( var_8 , var_7 . getOrDefault ( var_8 , 0 ) + 1 ) ;
  }
  List < String > var_16 = new ArrayList ( var_7 . keySet ( ) ) ;
  Collections . sort ( var_16 , ( var_19 , var_20 ) -> var_7 . get ( var_19 ) . equals ( var_7 . get ( var_20 ) ) ? var_19 . compareTo ( var_20 ) : var_7 . get ( var_20 ) - var_7 . get ( var_19 ) ) ;
  return var_16 . subList ( 0 , var_3 ) ;
}
