2160. Minimum Sum of Four Digit Number After Splitting Digits Easy

@problem@discussion
#Math#Greedy#Sorting



1/**
2 * [2160] Minimum Sum of Four Digit Number After Splitting Digits
3 *
4 * You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.
5 * 
6 * 	For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
7 * 
8 * Return the minimum possible sum of new1 and new2.
9 *  
10 * Example 1:
11 * 
12 * Input: num = 2932
13 * Output: 52
14 * Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
15 * The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
16 * 
17 * Example 2:
18 * 
19 * Input: num = 4009
20 * Output: 13
21 * Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. 
22 * The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	1000 <= num <= 9999
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/
33// discuss: https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn minimum_sum(num: i32) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_2160() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.