Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

Students also viewed these Databases questions