subject

Write a function: class Solution { public int solution(int[] A); } 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 [1..1,000,000,000).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:30
Me2540 week 5 assignment what do i want to know?
Answers: 1
question
Computers and Technology, 22.06.2019 08:00
Apex q: what does a low employment rate indicate? a. not many people are earning high salaries b. not many people are going to college c. not many people are renting their homes d. not many people have jobs
Answers: 2
question
Computers and Technology, 22.06.2019 12:10
Linux is distributed under gnu gpl. why is this important? a. it ensures that only torvalds can profit from the sale of linux b. it prevents unknowledgeable users from downloading programs they don't know how to operate. c. it provides protection for the developers who created linux. d. it states that anyone can copy, modify, and share the program if changes are made public.
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
What are listed in the vertical columns across the top of the event editor? a. file names b. conditions c. check marks d. action types
Answers: 1
You know the right answer?
Write a function: class Solution { public int solution(int[] A); } that, given an array A consisting...
Questions
question
Mathematics, 12.02.2021 09:40
question
Mathematics, 12.02.2021 09:40
question
Mathematics, 12.02.2021 09:40
question
Mathematics, 12.02.2021 09:40
question
Mathematics, 12.02.2021 09:40
Questions on the website: 13722360