![etuck16](/avatars/18399.jpg)
etuck16
06.12.2021 •
Computers and Technology
You are given an array of integers. Your task is to create pairs of them, such that every created pair has the same sum. This sum is not specified, but the number of created pairs should be the maximum possible. Each array element may belong to one pair only.
Write a function
class Solution public int
solution (int[] A); }
that, given an array A consisting of N integers, returns the maximum possible number of pairs with the same sum.
Examples:
1. Given A = [1, 9, 8, 100, 2], the function should return 2. The pairs are (A[0]. A[1]) and (A[2], A[4]); the sum of each pair is 10.
2. Given A = [2, 2, 2, 3], the function should return 1. Although, for instance, A[0]+A[1] = A[0]+A[2], the pairs (A[0], A[1]) and (A[0], A[2]) cannot exist at the same time, because they both contain a common element, A[0].
Solved
Show answers
More tips
- C Computers and Internet Can You Insert a Regular SIM Card into an iPad? Let s Find Out...
- F Food and Cooking Лечо: вкусное и простое блюдо для любой кухни...
- H Health and Medicine Relieving Swelling in Legs: Causes and Ways to Alleviate the Symptom...
- S Style and Beauty How to Get Rid of a Bruise: Tips and Tricks...
Answers on questions: Computers and Technology
- C Computers and Technology You have just purchased a new hard drive to install in your Linux system. Before you can begin using the drive to store files, which of the following tasks must you complete?...
- C Computers and Technology Write a method that modifies an ArrayList, moving all strings starting with an uppercase letter to the front, without otherwise changing the order of the elements....
- C Computers and Technology The largest number of commercial artificial satellites sent into orbit during the 1990s was launched by a. western european nations b. the united states c. russia d. nato...
- B Biology Which of the following is necessary for a geothermal plant to function? Your biomass fossil fuels heated rock hydrogen sunlight...
- L Law Did USAS challenge relations of production, consumption, or both? Did it do so successfully? Explain your answer....
- M Mathematics Anybody want to get brainliest?? HELP!!!...
- H History Summarize the king s basic schedule with a short description (1-3 sentences) of each part of his day using the template provided: 8.30 am: the First Valet de Chambre woke...
- H History Multiple choice question. Identify how gender fair language can be realized....
- F French Quelles sont les oppositions mises en avant dans le métier de roi dans la tragédie du roi...
- H Health Plz, send n7des snap=hockeyshark2442...
Ответ: