comefrom: <awangdev>621. Task Scheduler_1.java
code: public int leastInterval(char[] tasks, int n) {
          if (tasks == null) return 0;
          
          PriorityQueue<Integer> pq = new PriorityQueue<>(26, Collections.reverseOrder());
          int[] counts = new int[26];
          for (char c : tasks) counts[c - 'A']++;
          for (int i = 0; i < counts.length; i++) {
              if (counts[i] > 0) pq.offer(counts[i]);
          }
  
          int count = 0;
          while (!pq.isEmpty()) {
              int k = n + 1; 
              List<Integer> list = new ArrayList<>();
              while (k > 0 && !pq.isEmpty()) {
                  Integer taskCount = pq.poll();
                  if (taskCount-- > 1) list.add(taskCount);
                  count++;
                  k--;
              }
  
              pq.addAll(list); 
              if (pq.isEmpty()) break;
              count += k; 
          }
          return count;
      }
masked: public int sample_funcname ( char [ ] var_0 , int var_1 ) {
    if ( var_0 == null ) return 0 ;
    PriorityQueue < Integer > var_2 = new PriorityQueue < > ( 26 , Collections . reverseOrder ( ) ) ;
    int [ ] var_3 = new int [ 26 ] ;
    for ( char var_4 : var_0 ) var_3 [ var_4 - 'A' ] ++ ;
    for ( int var_5 = 0 ;
    var_5 < var_3 . length ;
    var_5 ++ ) {
      if ( var_3 [ var_5 ] > 0 ) var_2 . offer ( var_3 [ var_5 ] ) ;
    }
    int var_6 = 0 ;
    while ( ! var_2 . isEmpty ( ) ) {
      int var_7 = var_1 + 1 ;
      List < Integer > var_8 = new ArrayList < > ( ) ;
      while ( var_7 > 0 && ! var_2 . isEmpty ( ) ) {
        Integer var_9 = var_2 . poll ( ) ;
        if ( var_9 -- > 1 ) var_8 . add ( var_9 ) ;
        var_6 ++ ;
        var_7 -- ;
      }
      var_2 . addAll ( var_8 ) ;
      if ( var_2 . isEmpty ( ) ) break ;
      var_6 += var_7 ;
    }
    return var_6 ;
  }
  