Question: USE C LANGUAGE Write a function: int solution (int A[], int N); that, given an array A consisting of N integers, returns the maximum sum

USE C LANGUAGE
USE C LANGUAGE Write a function: int solution (int A[], int N);

Write a function: int solution (int A[], int N); that, given an 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: 1. 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 pair sums up to 93. 2. 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. II 3. Given A = [51, 32, 43), the function should return -1, since all numbers in A have digits that add up to different, unique sums. Write an efficient algorithm for the following assumptions: N is an integer within the range [1..200,000); each element of array A is an integer within the range [1..1,000,000,000)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!