c++ solution using frequency array
Intuition\nMost significant digit will contribute the maximum amount to the sum ( 10\'s digit in this case )\n\n# Approach\nMake a frequnecy array storing the f
# Intuition\nMost significant digit will contribute the maximum amount to the sum ( 10\'s digit in this case )\n\n# Approach\nMake a frequnecy array storing the frequncy of each digit. As we know while summing 2 digit numbers, 10s digit would contribute the maximum to the sum so we aim to use the minimum possible digit as 10\'s digit. The first two digits in the sorted frequncy array would be the smallest so make them the 10\'s digit and the remaining two as the 1\'s digit.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\n#include <vector>\nclass Solution {\npublic:\n    int minimumSum(int num) {\n        vector <int> v(10,0);\n        int copy = num;\n        while(copy){\n            int rem = copy % 10;\n            v[rem] += 1;\n            copy /= 10;\n        }\n        int count = 2;\n        int ans = 0;\n        for( int i = 0; i < 10; i++ ){\n            while( v[i] != 0 ){\n                if(count > 0){\n                    ans += i * 10;\n                    count -= 1;\n                }\n                else{\n                    ans += i;\n                }\n                v[i] -= 1;\n            }\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'C++']