Simple java program for beginners
Intuition\nWhen i looked into the problem it was easier to judge because the number they will be give is strictly a 4-digit number. Considering that they are as
# Intuition\nWhen i looked into the problem it was easier to judge because the number they will be give is strictly a 4-digit number. Considering that they are asking the min sum.....lets say we have 2 and 4 , while combining it together 24 is smaller than 42 so we have sort and make sure the min digit is in the ten\'s position than in the ones\'s position.\n# Approach\nFirst the number is converted into an array by using the modulus concept which i assume you guys know and then add then sort the array.\n\nWhen you sort it the first two elements of the array are the two minimum digits, and the last two are larger digits.\n\nConstruct the new numbers n1 and n2 with the minimum digits in the tens place.\n\nAnd then return n1+n2\n# Complexity\n- Time complexity: O(1)\n- Space complexity: O(1)\n# Code\n```\nclass Solution {\n    public int minimumSum(int num) {\n        int[] arr = new int[4];\n        for(int i=0;i<4;i++){\n            arr[i] = num%10;\n            num/=10;\n        }\n        Arrays.sort(arr);\n        int n1 = (arr[0])*10 + arr[2];\n        int n2 = (arr[1])*10 + arr[3];\n        return n1+n2;\n    }\n}\n```\n\nPLS UPVOTE......
['Java']