Question: Use Python : Given an array of integers, return indices of two numbers such that they add up to a specific target. For example, given

Use Python : Given an array of integers, return indices of two numbers such that they add up to a specific target.

For example, given nums =[2,3,4,5,6,7,], target = 9

Because nums[0] + nums[5] = 2+7 = 9

nums[1] + nums[4] = 3+6 = 9

nums[2] + nums[3] = 4+5 = 9

Return [[0,5],[1,4],[2,3]]

Define a function with function name twoSum to solve this problem.

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!