Question: c++I've solved the two sum problem from leetcode using 2 pointers as well as brute forcing it and now I'm trying to solve it using

c++I've solved the two sum problem from leetcode using 2 pointers as well as brute forcing it and now I'm trying to solve it using a hash table however I'm having trouble returning the index instead of the values. I was thinking of pairing the valued with an index but unsure. please help

1+ #include class Solution ( public: 2- 3 2456789 p 10+ 11

1+ #include class Solution ( public: 2- 3 2456789 p 10+ 11 12 13 14- 15 16 17 18 19 20 vector twoSum (vector & nums, int target) { unordered_set hashTable; for (int i = 0; i < nums.size(); i++){ //for(int values nums) { int values = nums[i]; int potentialMatch target values; if(hashTable. find (potentialMatch) != hashTable.end()) # return vector (potentialMatch, values); estcase Run Code Result Debugger Your input Output else{ } return {}; Wrong Answer Runtime: 0 ms Expected hashTable.insert(values); [2,7,11,15] 9 [2,7] [0,1]

Step by Step Solution

3.40 Rating (159 Votes )

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 Programming Questions!