int ugly(int n){
        int arr[] = new int[n];
        int count = 1;
        arr[0] = 1;
        int i2 = 0;
        int i3 = 0;
        int i5 = 0;
        while(count < n){
            int minNumber = min(arr[i2] * 2, arr[i3] * 3, arr[i5] * 5);
            if(minNumber == arr[i2]*2){
                i2++;
            }
            if(minNumber == arr[i3]*3){
                i3++;
            }
            if(minNumber == arr[i5]*5){
                i5++;
            }
            arr[count++] = minNumber;
        }
        
        return arr[n-1];
    }
Date 03/08/2016
@author Tushar Roy

Find nth ugly number.

https://leetcode.com/problems/ugly-number-ii/
https://leetcode.com/problems/super-ugly-number/
http://www.geeksforgeeks.org/ugly-numbers/
src/com/interview/dynamic/UglyNumbers.java