C++ Solution || Naive Approach || Using Map
\nclass Solution {\npublic:\n    long long sum(int n){\n        string s=to_string(n);\n        long long ans =0;\n        for(int i=0;i<s.size();i++){\n       
```\nclass Solution {\npublic:\n    long long sum(int n){\n        string s=to_string(n);\n        long long ans =0;\n        for(int i=0;i<s.size();i++){\n            ans+=(s[i]-\'0\');\n        }\n        return ans;\n    }\n    pair<int,int> top(vector<int> arrA){\n\n        if(arrA.size()<2){\n           return {};\n        }\n\n        int first=INT_MIN;\n        int second=INT_MIN;\n\n        for (int i = 0; i <arrA.size() ; i++) {\n            int current = arrA[i];\n            if(first<current){\n                second = first;\n                first = current;\n            }else if(second<current){\n                second = current;\n            }\n        }\n        return {first,second};\n    }\n    int maximumSum(vector<int>& arr) {\n       long long int maxi=-1;\n\n        map<long long ,vector<int>>mp;\n        for(int i=0;i<arr.size();i++){\n            // long long aa=\n            mp[sum(arr[i])].push_back(arr[i]);\n        }\n        for(auto m:mp){\n            if(m.second.size()>=2){\n                pair<int,int>p=top(m.second);\n                if(maxi<p.first+p.second){\n                    maxi=p.first+p.second;\n                }\n            }\n        }\n        return maxi;\n    }\n};\n```
['C', 'C++']