solution to find digits problem on hacker rank.