O(N*N)-->O(N) Explanation||easy-understand
step 1 :first we store all the elements in the unorderedmap;\nstep 2 find the sum of the given number ;\nstep 3 we checks  the sum in te unorderedmap;\nstep 4 t
step 1 :first we store all the elements in the unorderedmap;\nstep 2 find the sum of the given number ;\nstep 3 we checks  the sum in te unorderedmap;\nstep 4 then store  max ans in the answer;\n**step 5 and also store the maximum element in the unorderedmap because next time if\nfind the those same number wose sum is equal to previous sum then\nwe add only those elemnts whose sum is maximum**\n\n\n\n\n\n**this solution gives TLE**\n```\nclass Solution {\npublic:\n  int  possible(int m)\n    {\n        int sum=0;\n        while(m>0)\n        {\n            int d=m%10;\n            sum=sum+d;\n            m/=10;\n        }\n        return sum;\n    }\n\n        int maximumSum(vector<int>& nums) {\n         int n=nums.size(),ans=-1;\n        for(int i=0;i<n;i++)\n        {\n             int ok=possible(nums[i]);\n          //  cout<<ok<<" "<<"\\n";\n            for(int j=i+1;j<n;j++)\n            {\n                int k=possible(nums[j]);\n                //cout<<k<<" "<<"\\n";\n                if(ok==k)\n                {\n                     int result=nums[i]+nums[j];\n                    ans=max(ans,result);\n                    \n                }\n            }\n           \n                \n                \n        }\n            return ans;\n    }\n};\n```\n\n\n\n\n**2nd solution **\n\n```\nclass Solution {\npublic:\n  int  possible(int m) // find sum of each elements\n    {\n        int sum=0;\n        while(m>0)\n        {\n            int d=m%10;\n            sum=sum+d;\n            m/=10;\n        }\n        return sum;\n    }\n\n    \n    \n        int maximumSum(vector<int>& nums) {\n         int n=nums.size(),ans=-1;\n         unordered_map<int,int>m; //store all the elements in te map;\n        for(int i=0;i<n;i++)\n        {\n             int sum=possible(nums[i]);\n            \n               \n            if(m.find(sum)==m.end())\n            {\n                m[sum]=nums[i];\n            }          \n                else\n                {\n                    ans=max(ans,nums[i]+m[sum]); //maximum ans store in ans;\n                    m[sum]=max(m[sum],nums[i]); //also store in the map maximum elements this is most important \n                }\n                \n        }\n            return ans;\n    }\n};
['C++']