3697. Compute Decimal Representation Easy
1/**
2 * [3697] Compute Decimal Representation
3 *
4 * You are given a positive integer n.
5 * 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.
6 * Express n as a sum of only base-10 components, using the fewest base-10 components possible.
7 * Return an array containing these base-10 components in descending order.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">n = 537</span>
12 * Output: <span class="example-io">[500,30,7]</span>
13 * Explanation:
14 * We can express 537 as 500 + 30 + 7. It is impossible to express 537 as a sum using fewer than 3 base-10 components.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">n = 102</span>
19 * Output: <span class="example-io">[100,2]</span>
20 * Explanation:
21 * We can express 102 as 100 + 2. 102 is not a base-10 component, which means 2 base-10 components are needed.
22 * </div>
23 * <strong class="example">Example 3:
24 * <div class="example-block">
25 * Input: <span class="example-io">n = 6</span>
26 * Output: <span class="example-io">[6]</span>
27 * Explanation:
28 * 6 is a base-10 component.
29 * </div>
30 *
31 * Constraints:
32 *
33 * 1 <= n <= 10^9
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/compute-decimal-representation/
39// discuss: https://leetcode.com/problems/compute-decimal-representation/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn decimal_representation(n: i32) -> Vec<i32> {
45 vec![]
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_3697() {
57 }
58}
59Back
© 2026 bowen.ge All Rights Reserved.