O(1) Solution True Optimal Solution Beats 100% code.
SummaryBeats 100% of codes O(1) solution!ApproachCalculating all possible combinations of num
example: 2932--> 29,32 22,93 92,23 .......etc.
finding minimum sum
# Summary
<!-- Describe your first thoughts on how to solve this problem. -->
Beats 100% of codes O(1) solution!
# Approach
<!-- Describe your approach to solving the problem. -->
Calculating all possible combinations of num
example: 2932--> 29,32 22,93 92,23 .......etc.
finding minimum sum of all pairs;
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# 1.Code Final Improved Readablity:
```java []
class Solution {
    public int minimumSum(int num) {
    //Seperate Each Digits:
        int d1 = num / 1000;
        int d2 = (num / 100) % 10;
        int d3 = (num / 10) % 10;
        int d4 = num % 10;
    // Generate Combinations:
        int a = d1 * 10 + d2;
        int b = d3 * 10 + d4;
        int c = d1 * 10 + d4;
        int d = d2 * 10 + d3;
        int e = d2 * 10 + d1;
        int f = d4 * 10 + d3;
        int g = d4 * 10 + d1;
        int h = d1 * 10 + d3;
        int i = d2 * 10 + d4;
        int j = d4 * 10 + d2;
        int k = d3 * 10 + d1;
    //return Minimum:
        return Math.min(a + b, Math.min(j + k, Math.min(b + e, Math.min(c + d, Math.min(d + g, Math.min(a + f, h + i))))));
    }
}
```

# 2.Code ProtoType:
```java []
class Solution {
    public int minimumSum(int num) {
        int a= (num/1000*10)+(num/100)%10;
        int b=(num%100);
        int c=(num/1000*10)+(num%10);
        int d=(num%1000)/10;
        int e = ((num/100)%10)*10+(num/1000);  
        int f=(num%10)*10+(num%100)/10;
        int g=num%10*10+num/1000;
        int h=num/1000*10+(num%100)/10;
        int i=((num/100)%10)*10+num%10;
        int j=num%10*10+(num%1000)/100;
        int k=(num%100)/10*10+num/1000;
        return Math.min(a+b,Math.min(j+k,Math.min(b+e,Math.min(c+d,Math.min(d+g,Math.min(a+f,h+i))))));
    }
}
```
['Math', 'Greedy', 'C', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']