1. Engineering
  2. Computer Science
  3. please use python3 to solve the following question sample input...

Question: please use python3 to solve the following question sample input...

Question details

Please Use Python3 to solve the following question:

In this challenge, you will be given an array of integers and a target value. Determine the number of distinct pairs of elements in the array that sum to the target value. Two pairs (a, b) and (c d) are considered to be distinct if and only if the values in sorted order do not match, i.e., (1,9) and (9, 1) are indistinct but (1, 9) and (9, 2) are distinct For instance, given the array 11, 2, 3,6,7,8,9,11, and a target value of 10, the seven pairs (1,9).(2,8),(3,7),(8,2),(9,1).(9,1), and (1, 9) all sum to 10 and only three distinct pairs: (1,9),(2,8) and (3,7 Function Description Complete the function numberOfPairs in the editor below. The function must return an integer, the total number of distinct pairs of elements in the array that sum to the target value numberOfPairs has the following parameter(s) alafO]...aln-1): an array of integers to select pairs from k: target integer value to sum to Constraints 1sns5 x105 0sks5x 109

Sample input: [6,6,3,9,3,5,1], k = 12

output : 2

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution