# Maximum Sum of Two Numbers (Microsoft Online Onsite Interview-Codility platform)

Write a function given array A consisting of N integers, returns the maximum sum of two numbers whose digits add up to an equal sum. If there are no two numbers whose digits have an equal sum, the function should return -1.

Examples:

Given A =[51, 71, 17, 42], the function should return 93. There are two pairs of numbers whose digits add up to an equal sum: (51,42) and(17,71). The first pairs sums up to 93.

Given A =[42, 33, 60], the function should return 102. The digits of all numbers in A add up to the same sum, and choosing to add 42 and 60 gives the result 102.

Given A =[51, 32, 43], the function should return -1, since all numbers in A have digits that add up to different, unique sums

--

--

--

## More from Jaydeep

Full Stack Programmer, love to solve problem’s during free time.

Love podcasts or audiobooks? Learn on the go with our new app.

## Jaydeep

Full Stack Programmer, love to solve problem’s during free time.