Question: 3. Given an integer vector and an integer target, write a function that returns an integer pointer pointing at an array containing indices of the

3. Given an integer vector and an integer target, write a function that returns an integer pointer pointing at an array containing indices of the two numbers such that they add up to the target. Return nullptr if there is no solution.

GIVEN CODES:

/******************************************************************************

Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/ #include #include #include #include #include #include

using namespace std;

//Code your twoSum(...) below

int main() {

vector nums; nums.push_back(41); nums.push_back(12); nums.push_back(3); nums.push_back(74); nums.push_back(51); int* pair = twoSum(nums, 53); if(pair) cout << pair[0] << " " << pair[1] << endl; else cout << "No solution"; return 0; }

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!