Question: Please answer using C language:- Write a function: int solution(int All, int N); that, given an array A consisting of N integers, returns the maximum

Please answer using C language:-

Write a function: int solution(int All, 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 I 60 gives the result 102.

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].

Please answer using C language:- Write a function: int solution(int All, int

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. 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 Copyright 2009-2022 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited

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!