3300. Minimum Element After Replacement With Digit Sum Easy

@problem@discussion
#Array#Math



1/**
2 * [3300] Minimum Element After Replacement With Digit Sum
3 *
4 * You are given an integer array nums.
5 * You replace each element in nums with the sum of its digits.
6 * Return the minimum element in nums after all replacements.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums = [10,12,13,14]</span>
11 * Output: <span class="example-io">1</span>
12 * Explanation:
13 * nums becomes [1, 3, 4, 5] after all replacements, with minimum element 1.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [1,2,3,4]</span>
18 * Output: <span class="example-io">1</span>
19 * Explanation:
20 * nums becomes [1, 2, 3, 4] after all replacements, with minimum element 1.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">nums = [999,19,199]</span>
25 * Output: <span class="example-io">10</span>
26 * Explanation:
27 * nums becomes [27, 10, 19] after all replacements, with minimum element 10.
28 * </div>
29 *  
30 * Constraints:
31 * 
32 * 	1 <= nums.length <= 100
33 * 	1 <= nums[i] <= 10^4
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/
39// discuss: https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn min_element(nums: Vec<i32>) -> i32 {
45        0
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_3300() {
57    }
58}
59


Back
© 2025 bowen.ge All Rights Reserved.