comefrom: <awangdev>Minimum Height Trees_1.java
code: public List<Integer> findMinHeightTrees(int n, int[][] edges) {
          List<Integer> rst = new ArrayList<Integer>();
          if (n == 1) {
              rst.add(0);
              return rst;
          }else if (n == 0 || edges == null || edges.length == 0 || edges.length != n - 1) {
              return rst;
          }
          
          boolean[] nodes = new boolean[n];
          HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();
          for (int i = 0; i < n; i++) {
              map.put(i, new ArrayList<Integer>());
              nodes[i] = true;
          }
          for (int i = 0; i < edges.length;  i++) {        
              if (!map.get(edges[i][0]).contains(edges[i][1])) {
                  map.get(edges[i][0]).add(edges[i][1]);
              }   
              if (!map.get(edges[i][1]).contains(edges[i][0])) {
                  map.get(edges[i][1]).add(edges[i][0]);
              }  
          } 
          
          Queue<Integer> queue = new LinkedList<Integer>();
          while (n > 2) {
              for (Map.Entry<Integer, ArrayList<Integer>> entry : map.entrySet()) {
                  if (entry.getValue().size() == 1) {
                      queue.offer(entry.getKey());
                  }
              }
              while (!queue.isEmpty()) {
                  n--;
                  Integer key = queue.poll();
                  nodes[key] = false;
                  int from = map.get(key).get(0);
                  map.get(from).remove(key);
                  map.get(key).remove(0);
                  
              }
          }
          
          for (int i = 0; i < nodes.length; i++) {
              if (nodes[i]) {
                  rst.add(i);
              }
  
          }
          
          return rst;
      }
masked: public List < Integer > var_1 ( int var_2 , int [ ] [ ] var_3 ) {
    List < Integer > var_6 = new ArrayList < Integer > ( ) ;
    if ( var_2 == 1 ) {
      var_6 . add ( 0 ) ;
      return var_6 ;
    }
    else if ( var_2 == 0 || var_3 == null || var_3 . length == 0 || var_3 . length != var_2 - 1 ) {
      return var_6 ;
    }
    boolean [ ] var_13 = new boolean [ var_2 ] ;
    HashMap < Integer , ArrayList < Integer >> var_15 = new HashMap < Integer , ArrayList < Integer >> ( ) ;
    for ( int var_16 = 0 ;
    var_16 < var_2 ;
    var_16 ++ ) {
      var_15 . put ( var_16 , new ArrayList < Integer > ( ) ) ;
      var_13 [ var_16 ] = true ;
    }
    for ( int var_16 = 0 ;
    var_16 < var_3 . length ;
    var_16 ++ ) {
      if ( ! var_15 . get ( var_3 [ var_16 ] [ 0 ] ) . contains ( var_3 [ var_16 ] [ 1 ] ) ) {
        var_15 . get ( var_3 [ var_16 ] [ 0 ] ) . add ( var_3 [ var_16 ] [ 1 ] ) ;
      }
      if ( ! var_15 . get ( var_3 [ var_16 ] [ 1 ] ) . contains ( var_3 [ var_16 ] [ 0 ] ) ) {
        var_15 . get ( var_3 [ var_16 ] [ 1 ] ) . add ( var_3 [ var_16 ] [ 0 ] ) ;
      }
    }
    Queue < Integer > var_22 = new LinkedList < Integer > ( ) ;
    while ( var_2 > 2 ) {
      for ( Map . Entry < Integer , ArrayList < Integer >> var_25 : var_15 . entrySet ( ) ) {
        if ( var_25 . getValue ( ) . size ( ) == 1 ) {
          var_22 . offer ( var_25 . getKey ( ) ) ;
        }
      }
      while ( ! var_22 . isEmpty ( ) ) {
        var_2 -- ;
        Integer var_32 = var_22 . poll ( ) ;
        var_13 [ var_32 ] = false ;
        int var_33 = var_15 . get ( var_32 ) . get ( 0 ) ;
        var_15 . get ( var_33 ) . remove ( var_32 ) ;
        var_15 . get ( var_32 ) . remove ( 0 ) ;
      }
    }
    for ( int var_16 = 0 ;
    var_16 < var_13 . length ;
    var_16 ++ ) {
      if ( var_13 [ var_16 ] ) {
        var_6 . add ( var_16 ) ;
      }
    }
    return var_6 ;
  }
  