C++ | Easy Solution | 100% Fast | With Approach
First we create vector of pairs, the first part of pair is also a pair which is the sum of digit of number and the number itself and second is it\'s index.\nThe
First we create vector of pairs, the first part of pair is also a pair which is the sum of digit of number and the number itself and second is it\'s index.\nThen we apply sorting on the vector, so first the vector will be sorted based on the maximum sum of digits then with the number.\nFor eg:- \n234, 81, 9, 44, 26, 8, 14, 5, 2 (First sorted according to digits sum, and then sorted according to number)\nThen we compare if the sum of digits is equal to it\'s next then we store it our answer, and also keep the track of maximum value while iterating the vector.\nTime Complexity - **O(NlogN)**\nSpace Complexity - **O(N)**\n```\n\tint maximumSum(vector<int>& nums) \n    {\n        int n=nums.size(),x,y;\n        vector<pair<pair<int,int>,int>> v;\n        for(int i=0;i<n;i++)\n        {\n            int x=nums[i],sum=0;\n            while(x!=0)\n            {\n                sum+=x%10;\n                x/=10;\n            }\n            v.push_back({{sum,nums[i]},i});\n        }\n        sort(v.rbegin(),v.rend());\n        if(n>1)\n        {\n            int ans=-1;\n            for(int i=0;i<n-1;i++)            \n            {\n                if(v[i].first.first==v[i+1].first.first)\n                {\n                    ans=max(ans,nums[v[i].second]+nums[v[i+1].second]);\n                }\n            }\n            return ans;\n        }\n        else \n            return -1;\n    }\n```\nThis is my first post on Leetcode Discussion hope you find it helpful and understanding. :)
['C', 'Sorting']