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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started