comefrom: <awangdev>1203. Sort Items by Groups Respecting Dependencies_2.java
code: private List<Integer> topoSort(Map<Integer, List<Integer>> graph, Set<Integer> set) {
  
          Map<Integer, Integer> indegree = new HashMap<>();
          for (int item : set) { 
              indegree.put(item, 0);
          }
          for (int node : graph.keySet()) { 
              if (!set.contains(node)) continue; 
              for (int parent : graph.get(node)) { 
                  indegree.put(parent, indegree.get(parent) + 1);
              }
          }
          Queue<Integer> queue = new LinkedList<>();
          for (int key : indegree.keySet()) {
              if (indegree.get(key) == 0) queue.offer(key);
          }
          
          List<Integer> rst = new ArrayList<>();
          while (!queue.isEmpty()) {
              int node = queue.poll();
              rst.add(node);
              if (!graph.containsKey(node)) continue;
              for (int parent : graph.get(node)) {
                  indegree.put(parent, indegree.get(parent) - 1);
                  if (indegree.get(parent) == 0) queue.offer(parent);
              }
          }
          
          return rst;
      }
masked: private List < Integer > var_1 ( Map < Integer , List < Integer >> var_4 , Set < Integer > var_6 ) {
    Map < Integer , Integer > var_8 = new HashMap < > ( ) ;
    for ( int var_9 : var_6 ) {
      var_8 . put ( var_9 , 0 ) ;
    }
    for ( int var_13 : var_4 . keySet ( ) ) {
      if ( ! var_6 . contains ( var_13 ) ) continue ;
      for ( int var_16 : var_4 . get ( var_13 ) ) {
        var_8 . put ( var_16 , var_8 . get ( var_16 ) + 1 ) ;
      }
    }
    Queue < Integer > var_20 = new LinkedList < > ( ) ;
    for ( int var_21 : var_8 . keySet ( ) ) {
      if ( var_8 . get ( var_21 ) == 0 ) var_20 . offer ( var_21 ) ;
    }
    List < Integer > var_24 = new ArrayList < > ( ) ;
    while ( ! var_20 . isEmpty ( ) ) {
      int var_13 = var_20 . poll ( ) ;
      var_24 . add ( var_13 ) ;
      if ( ! var_4 . containsKey ( var_13 ) ) continue ;
      for ( int var_16 : var_4 . get ( var_13 ) ) {
        var_8 . put ( var_16 , var_8 . get ( var_16 ) - 1 ) ;
        if ( var_8 . get ( var_16 ) == 0 ) var_20 . offer ( var_16 ) ;
      }
    }
    return var_24 ;
  }
  