2578. Split With Minimum Sum Easy

@problem@discussion
#Math#Greedy#Sorting



1/**
2 * [2578] Split With Minimum Sum
3 *
4 * Given a positive integer num, split it into two non-negative integers num1 and num2 such that:
5 * 
6 * 	The concatenation of num1 and num2 is a permutation of num.
7 * 	
8 * 		In other words, the sum of the number of occurrences of each digit in num1 and num2 is equal to the number of occurrences of that digit in num.
9 * 	
10 * 	
11 * 	num1 and num2 can contain leading zeros.
12 * 
13 * Return the minimum possible sum of num1 and num2.
14 * Notes:
15 * 
16 * 	It is guaranteed that num does not contain any leading zeros.
17 * 	The order of occurrence of the digits in num1 and num2 may differ from the order of occurrence of num.
18 * 
19 *  
20 * <strong class="example">Example 1:
21 * 
22 * Input: num = 4325
23 * Output: 59
24 * Explanation: We can split 4325 so that num1 is 24 and num2 is 35, giving a sum of 59. We can prove that 59 is indeed the minimal possible sum.
25 * 
26 * <strong class="example">Example 2:
27 * 
28 * Input: num = 687
29 * Output: 75
30 * Explanation: We can split 687 so that num1 is 68 and num2 is 7, which would give an optimal sum of 75.
31 * 
32 *  
33 * Constraints:
34 * 
35 * 	10 <= num <= 10^9
36 * 
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/split-with-minimum-sum/
41// discuss: https://leetcode.com/problems/split-with-minimum-sum/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46    pub fn split_num(num: i32) -> i32 {
47        0
48    }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_2578() {
59    }
60}
61


Back
© 2025 bowen.ge All Rights Reserved.