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_2 ) {
    if ( var_2 == null || var_2 . length ( ) == 0 ) return "" ;
    Map < Character , Integer > var_11 = new HashMap < > ( ) ;
    for ( char var_13 : var_2 . toCharArray ( ) ) {
      var_11 . put ( var_13 , var_11 . getOrDefault ( var_13 , 0 ) + 1 ) ;
    }
    PriorityQueue < Map . Entry < Character , Integer >> var_22 = new PriorityQueue < > ( ( var_20 , var_19 ) -> ( var_19 . getValue ( ) - var_20 . getValue ( ) ) ) ;
    var_22 . addAll ( var_11 . entrySet ( ) ) ;
    StringBuilder var_26 = new StringBuilder ( ) ;
    Queue < Map . Entry < Character , Integer >> var_29 = new LinkedList < > ( ) ;
    while ( ! var_22 . isEmpty ( ) ) {
      Map . Entry < Character , Integer > var_32 = var_22 . poll ( ) ;
      var_26 . append ( var_32 . getKey ( ) ) ;
      var_32 . setValue ( var_32 . getValue ( ) - 1 ) ;
      var_29 . offer ( var_32 ) ;
      if ( var_29 . size ( ) == 2 ) {
        Map . Entry < Character , Integer > var_39 = var_29 . poll ( ) ;
        if ( var_39 . getValue ( ) > 0 ) var_22 . offer ( var_39 ) ;
      }
    }
    return var_26 . length ( ) == var_2 . length ( ) ? var_26 . toString ( ) : "" ;
  }
  