<awangdev>Ugly Number II_3.java
public int nthUglyNumber(int n) {
        if (n <= 0) {
        	return 0;
        } else if (n == 1) {
        	return 1;
        }
        long[] dp = new long[n + 1];
        dp[0] = 0;
        dp[1] = 1;

        PriorityQueue<Long> candidate = new PriorityQueue<Long>();
		HashSet<Long> set = new HashSet<Long>();
		set.add(dp[1]);
		for (int i = 2; i <= n; i++) {
			if (!set.contains(dp[i - 1] * 2)) {
				candidate.add(dp[i - 1] * 2);
				set.add(dp[i - 1] * 2);
			}
			if (!set.contains(dp[i - 1] * 3)) {
				candidate.add(dp[i - 1] * 3);
				set.add(dp[i - 1] * 3);
			}
			if (!set.contains(dp[i - 1] * 5)) {
				candidate.add(dp[i - 1] * 5);
				set.add(dp[i - 1] * 5);
			}
			dp[i] = candidate.poll();
		}

		return (int)dp[n];
    }
public int sample_funcname ( int var_0 ) {
  if ( var_0 <= 0 ) {
    return 0 ;
  }
  else if ( var_0 == 1 ) {
    return 1 ;
  }
  long [ ] var_3 = new long [ var_0 + 1 ] ;
  var_3 [ 0 ] = 0 ;
  var_3 [ 1 ] = 1 ;
  PriorityQueue < Long > var_6 = new PriorityQueue < Long > ( ) ;
  HashSet < Long > var_8 = new HashSet < Long > ( ) ;
  var_8 . add ( var_3 [ 1 ] ) ;
  for ( int var_11 = 2 ;
  var_11 <= var_0 ;
  var_11 ++ ) {
    if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 2 ) ) {
      var_6 . add ( var_3 [ var_11 - 1 ] * 2 ) ;
      var_8 . add ( var_3 [ var_11 - 1 ] * 2 ) ;
    }
    if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 3 ) ) {
      var_6 . add ( var_3 [ var_11 - 1 ] * 3 ) ;
      var_8 . add ( var_3 [ var_11 - 1 ] * 3 ) ;
    }
    if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 5 ) ) {
      var_6 . add ( var_3 [ var_11 - 1 ] * 5 ) ;
      var_8 . add ( var_3 [ var_11 - 1 ] * 5 ) ;
    }
    var_3 [ var_11 ] = var_6 . poll ( ) ;
  }
  return ( int ) var_3 [ var_0 ] ;
}
