[Daily Coding Problem 70] Nth perfect number

This problem was asked by Microsoft.

A number is considered perfect if its digits sum up to exactly 10.

Given a positive integer n, return the n-th perfect number.

For example, given 1, you should return 19. Given 2, you should return 28.

 

This is one of the problem where you can scratch your head for hours, trying to come up with a "smart" solution but just can't. Unfortunately, it doesn't seem like there's a faster way than simply iterating over all the numbers and keeping track of the current perfect number until we hit n

 

posted @ 2019-02-06 01:14  Review->Improve  阅读(196)  评论(0编辑  收藏  举报