|| Simple Approach ||
\n\n# Approach\nWe sort the given number.\nThen, to minimize the sum formed by nums1 and nums2 as required,\nIt is obvious that we should generate 2 digit 2 num
\n\n# Approach\nWe sort the given number.\nThen, to minimize the sum formed by nums1 and nums2 as required,\nIt is obvious that we should generate 2 digit 2 numbers as their sum would be lesser than a 3 digit number and a 1 digit number.\n\nHence to generate the minimum sum,\nTo minimize the numbers created,\nWe club together the smallest digit followed by greatest digit.\nWe club together the second smallest digit number followed by second greatest digit.\n\nSTEPS :\n1> Sort the Number Digits.\n2> Generate the nums1 as 1st Digit followed by 4th Digit.\n3> Generate the nums2 as 2nd Digit followed by 3d Digit.\n4> Return the minimum sum, as nums1 + nums2.\n\nFor example,\n2932\n-> 2239\nWe make the numbers as 29 and 23. Which give the Minimum Sum.\n\n4009\n-> 0049\nWe make the numbers 09 and 04. Which give the Minimum Sum.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity Analysis\n# Time Complexity: O(NlogN)\nAlmost Constant Time Algorithm.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Space complexity: O(1)\nAlmost Constant Space Algorithm.\n<!-- Add your space cmathomplexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSum(int num) \n    {\n        string nums = to_string(num);\n        sort(nums.begin(),nums.end());\n        char nums1 = nums[0];\n        char nums2 = nums[1];\n        char nums3 = nums[2];\n        char nums4 = nums[3];\n\n        string ans1 = "";\n        ans1 += nums1;\n        ans1 += nums4;\n        string ans2 = "";\n        ans2 += nums2;\n        ans2 += nums3;\n\n        return stoi(ans1) + stoi(ans2);\n\n    }\n};\n```
['Math', 'C++']