Class Solution
- java.lang.Object
-
- g2101_2200.s2160_minimum_sum_of_four_digit_number_after_splitting_digits.Solution
-
public class Solution extends Object
2160 - Minimum Sum of Four Digit Number After Splitting Digits.Easy
You are given a positive integer
numconsisting of exactly four digits. Splitnuminto two new integersnew1andnew2by using the digits found innum. Leading zeros are allowed innew1andnew2, and all the digits found innummust be used.- For example, given
num = 2932, you have the following digits: two2’s, one9and one3. Some of the possible pairs[new1, new2]are[22, 93],[23, 92],[223, 9]and[2, 329].
Return the minimum possible sum of
new1andnew2.Example 1:
Input: num = 2932
Output: 52
Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
Example 2:
Input: num = 4009
Output: 13
Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc.
The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
Constraints:
1000 <= num <= 9999
- For example, given
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intminimumSum(int num)
-