Java Detailed Solution - O(nlog(n))
Intuition\n> Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.\n> Return the minimum possible sum of new1 and new2.\n\nI
# Intuition\n> Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.\n> Return the minimum possible sum of new1 and new2.\n\nIt is easy to see that when given a 4-digit number, a pair of two-digit numbers is always smaller than a pair consisting of a 3-digit and 1-digit number. On closer inspection, the position that can make a 2-digit number significantly smaller is the tens place. For instance, if we have digits 0 and 1, 01 is smaller than 10 (given that trailing zeros are allowed). Thus, to make the two 2-digit numbers as small as possible, we can place the two minimum values in the tens place of the 4-digit number and put the larger ones in the ones place.\n\n# Approach\n1. Split the given number `num` into four separate digits. We can use an array to store these digits.\n    - To get the four digits, simply modulo by 10 to get the numbers starting from the ones, repetitively until `num` is 0.\n2. Sort the array.\n    - This way, the first two elements of the array are the two minimum digits, and the last two are larger digits.\n3. Construct the new numbers `new1` and `new2` with the minimum digits in the tens place. \n4. Return the sum of `new1` and `new2`. Since these are the two minimum numbers, the sum will also be the minimum.\n# Complexity\n- Time complexity: $$O(nlog(n))$$ where $$n$$ is always 4, which is the amount of digits of the number.\n\n- Space complexity: $$O(n)$$ where $$n$$ is is always 4, which is the amount of digits of the number. Remember, we use an array to store the digits.\n\n# Code\n```\nclass Solution {\n    public int minimumSum(int num) {\n        int[] digits = new int[4];\n        for(int i = 0; i < 4; i++) {\n            digits[i] = num % 10;\n            num /= 10;\n        }\n        Arrays.sort(digits);\n        int new1 = digits[0] * 10 + digits[2];\n        int new2 = digits[1] * 10 + digits[3];\n\n        return new1 + new2;\n    }\n}\n```
['Java']