JuniorArrayMath

Compute Decimal Representation

You are given a positive integer n.

A positive integer is a base-10 component if it is the product of a single digit from 1 to 9 and a non-negative power of 10. For example, 500, 30, and 7 are base-10 components, while 537, 102, and 11 are not.

Express n as a sum of only base-10 components, using the fewest base-10 components possible.

Return an array containing these base-10 components in descending order.

Example 1
Inputn = 537
Output[500,30,7]
We can express 537 as 500 + 30 + 7, and it is impossible to express 537 as a sum using fewer than 3 base-10 components.
Example 2
Inputn = 102
Output[100,2]
We can express 102 as 100 + 2; since 102 is not a base-10 component, 2 base-10 components are needed.

Constraints

  • 1 <= n <= 10^9

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate