Ugly Number II

Ugly number is a number that only have factors 23and 5.

Design an algorithm to find the nth ugly number. The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12...

Notice

Note that 1 is typically treated as an ugly number.

Example

If n=9, return 10.

Challenge 

O(n log n) or O(n) time.

这道题需要明天看一下。

posted @ 2017-01-10 09:42  璨璨要好好学习  阅读(95)  评论(0编辑  收藏  举报