Question: use Python Given a string of integer arrays and the expected sum, and through the program, in the input integer array, find the directory position

use Python

Given a string of integer arrays and the expected sum, and through the program, in the input integer array, find the directory position (index) of two integers whose sum is equal to the expected sum. Assume that the input integer array does have only one combination, the numbers in the integer array will not repeat, and the length of the array is not less than 1.

Example: integer array is 2 7 5 11 The expected sum is 9 So the output value is 0 1

input: The first line at the beginning represents the number of test data. Next, each set of test data has three rows. The positive integer in the first line is n, representing the length of this array. The second line of integers is m, representing the expected sum of this array. The third line has n integers, representing this array of integers. Each integer is separated by a half-width blank. Please refer to Sample input.

output: For each set of test data, output the directory (index) position of two integers in the integer array, and the two integers meet the requirement that the sum is equal to the expected sum. Each integer directory location is separated by a semi-white space.

input output
2 0 1
4 1 2
9
2 7 5 11
3
6
3 2 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!