comefrom: <awangdev>767. Reorganize String_1.java
code: public String reorganizeString(String S) {
          if (S == null || S.length() == 0) return "";
          Map<Character, Integer> map = new HashMap<>();
          for (char c : S.toCharArray()) {
              map.put(c, map.getOrDefault(c, 0) + 1);
          }
          PriorityQueue<Map.Entry<Character, Integer>> pq = new PriorityQueue<>((a, b) -> (b.getValue() - a.getValue()));
          pq.addAll(map.entrySet());
          StringBuilder sb = new StringBuilder();
          Queue<Map.Entry<Character, Integer>> buffer = new LinkedList<>();
          while (!pq.isEmpty()) {
              Map.Entry<Character, Integer> entry = pq.poll();
              sb.append(entry.getKey());
              entry.setValue(entry.getValue() - 1);
              buffer.offer(entry);
              if (buffer.size() == 2) {
                  Map.Entry<Character, Integer> temp = buffer.poll();
                  if (temp.getValue() > 0) pq.offer(temp);
              }
          }
          return sb.length() == S.length() ? sb.toString() : "";
      }
masked: public String var_0 ( String var_1 ) {
    if ( var_1 == null || var_1 . length ( ) == 0 ) return "" ;
    Map < Character , Integer > var_2 = new HashMap < > ( ) ;
    for ( char var_3 : var_1 . toCharArray ( ) ) {
      var_2 . put ( var_3 , var_2 . getOrDefault ( var_3 , 0 ) + 1 ) ;
    }
    PriorityQueue < Map . Entry < Character , Integer >> var_6 = new PriorityQueue < > ( ( var_5 , var_4 ) -> ( var_4 . getValue ( ) - var_5 . getValue ( ) ) ) ;
    var_6 . addAll ( var_2 . entrySet ( ) ) ;
    StringBuilder var_7 = new StringBuilder ( ) ;
    Queue < Map . Entry < Character , Integer >> var_8 = new LinkedList < > ( ) ;
    while ( ! var_6 . isEmpty ( ) ) {
      Map . Entry < Character , Integer > var_9 = var_6 . poll ( ) ;
      var_7 . append ( var_9 . getKey ( ) ) ;
      var_9 . setValue ( var_9 . getValue ( ) - 1 ) ;
      var_8 . offer ( var_9 ) ;
      if ( var_8 . size ( ) == 2 ) {
        Map . Entry < Character , Integer > var_10 = var_8 . poll ( ) ;
        if ( var_10 . getValue ( ) > 0 ) var_6 . offer ( var_10 ) ;
      }
    }
    return var_7 . length ( ) == var_1 . length ( ) ? var_7 . toString ( ) : "" ;
  }
  