Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, justbepunky
There is a simple pattern for determining if a binary number is odd. what is it and why does this pattern occur? how many bits would you need if you wanted to have the ability to count up to 1000? how high could you count in binary if you used all 10 of your fingers as bits? (finger up means 1, finger down means 0)
Answers: 3
image
Computers and Technology, 22.06.2019 13:30, baeethtsadia
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
image
Computers and Technology, 22.06.2019 21:50, IdkHowToDoMath
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
image
Computers and Technology, 23.06.2019 20:30, summerhumphries3
What are some settings you can control when formatting columns?
Answers: 1
Do you know the correct answer?
Write a function: class Solution { public int solution(int[] A); } that, given an array A consisting...

Questions in other subjects:

Konu
Mathematics, 15.06.2020 05:57