Simple method with time 2ms and space required 6.44MB.
Intuition\n Describe your first thoughts on how to solve this problem. \nHow about storing each element/digit of the number in a vector of int type and then sor
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nHow about storing each element/digit of the number in a vector of `int` type and then sorting it in ascending order, then adding the two terms formed from the first and fourth(last) element along with the second and the third element.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe detailed explanation of the program is as:\n1. A vector of integers named `res` is initialized.\n2. A while loop is executed as long as the variable `num` is non-zero.\n3. Inside the loop, the value of `num` is appended to the `res` vector using the `push_back()` function.\n4. The value of `num` is divided by 10 in each iteration to extract the digits.\n5. After the loop, the `res` vector is sorted in ascending order using the `sort()` function.\n6. Two new variables, `num1` and `num2`, are calculated by combining specific elements from the sorted "res" vector.\n7. Finally, the sum of `num1` and `num2` is returned.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n logn) \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSum(int num) {\n        vector<int> res;\n        while(num)\n        {\n            res.push_back(num%10);\n            num/=10;\n        }\n        sort(res.begin(),res.end());\n        int num1=(res[0]*10)+res[3];\n        int num2=(res[1]*10)+res[2];\n        return num1+num2;\n    }\n};\n```
['Array', 'Greedy', 'Sorting', 'C++']