CodeSignal/Arcade

CodeSignal [56/60] digitsProduct

벤진[Benzene] 2020. 5. 28. 12:33

Problem:

Given an integer product, find the smallest positive (i.e. greater than 0) integer the product of whose digits is equal to product. If there is no such integer, return -1 instead.

 

Example

  • For product = 12, the output should be
    digitsProduct(product) = 26;
  • For product = 19, the output should be
    digitsProduct(product) = -1.

-Summary-

1. we search the number from 1 to 10000.

2. change the number to the string to calculate the product of each number in the number. (Ex. '12' = 1 and 2 --> 1*2 = 2)

3. Once we found the number i which product of each number is the same as product give.

4. return with smallest product number.

모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]

https://codesignal.com/