<awangdev>Perfect Squares_3.java
public int numSquares(int n) {
        if (n <= 0) {
            return 0;
        }
        Queue<Integer> queue = new LinkedList<>();
        Set<Integer> set = new HashSet<>(); 
        queue.offer(n);
        int level = 1;
        while (!queue.isEmpty()) {
            int size = queue.size();
            for (int x = 0; x < size; x++) {
                int num = queue.poll();
                for (int i = 1; i <= num; i++) {
                    int remain = num - i * i;
                    if (remain == 0) {
                        return level;
                    } else if (remain > 0 && !set.contains(remain)) {
                        queue.offer(remain);
                        set.add(remain);
                    } else if (remain < 0) {
                        break;
                    }
                }
            }
            level++;
        }
        return level;
    }
public int sample_funcname ( int var_0 ) {
  if ( var_0 <= 0 ) {
    return 0 ;
  }
  Queue < Integer > var_5 = new LinkedList < > ( ) ;
  Set < Integer > var_8 = new HashSet < > ( ) ;
  var_5 . offer ( var_0 ) ;
  int var_11 = 1 ;
  while ( ! var_5 . isEmpty ( ) ) {
    int size = var_5 . size ( ) ;
    for ( int var_14 = 0 ;
    var_14 < size ;
    var_14 ++ ) {
      int var_16 = var_5 . poll ( ) ;
      for ( int var_17 = 1 ;
      var_17 <= var_16 ;
      var_17 ++ ) {
        int var_18 = var_16 - var_17 * var_17 ;
        if ( var_18 == 0 ) {
          return var_11 ;
        }
        else if ( var_18 > 0 && ! var_8 . contains ( var_18 ) ) {
          var_5 . offer ( var_18 ) ;
          var_8 . add ( var_18 ) ;
        }
        else if ( var_18 < 0 ) {
          break ;
        }
      }
    }
    var_11 ++ ;
  }
  return var_11 ;
}
