Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Outlook 2023

Authors: James Holler

1st Edition

B0BP9P1VWJ, 979-8367217322

More Books

Students also viewed these Databases questions

Question

6. What problems can GM-Daewoo expect in the future?

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago