본문 바로가기
CodeSignal/Arcade

CodeSignal [56/60] digitsProduct

by 벤진[Benzene] 2020. 5. 28.

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/

'CodeSignal > Arcade' 카테고리의 다른 글

CodeSignal [58/60] messageFromBinaryCode  (0) 2020.05.28
CodeSignal [57/60] fileNaming  (0) 2020.05.28
CodeSignal [55/60] differentSquares  (0) 2020.05.28
CodeSignal [54/60] sumUpNumbers  (0) 2020.05.28
CodeSignal [53/60] validTime  (0) 2020.05.28

댓글