<awangdev>1203. Sort Items by Groups Respecting Dependencies_1.java
private Map<Integer, List<Integer>> buildGroup(int n, int m, int[] group) {

        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int groupId = group[i] == -1 ? m++ : group[i];
            group[i] = groupId;
            map.putIfAbsent(groupId, new ArrayList<>());
            map.get(groupId).add(i);
        }
        return map;
    }
private Map < Integer , List < Integer >> var_2 ( int var_3 , int var_4 , int [ ] var_5 ) {
  Map < Integer , List < Integer >> var_8 = new HashMap < > ( ) ;
  for ( int var_10 = 0 ;
  var_10 < var_3 ;
  var_10 ++ ) {
    int var_12 = var_5 [ var_10 ] == - 1 ? var_4 ++ : var_5 [ var_10 ] ;
    var_5 [ var_10 ] = var_12 ;
    var_8 . putIfAbsent ( var_12 , new ArrayList < > ( ) ) ;
    var_8 . get ( var_12 ) . add ( var_10 ) ;
  }
  return var_8 ;
}
