Read the following code :
int func(vector& v, int target)
{
int result = 0;
unordered_map < int, int > myMap;
for(int x : v)
{
result += myMap[target - x];
myMap[x]++;
}
return result;
}
What is returned by the above code?
Read the following code :
int func(vector& v, int target)
{
int result = 0;
unordered_map < int, int > myMap;
for(int x : v)
{
result += myMap[target - x];
myMap[x]++;
}
return result;
}
What is returned by the above code?
It would return the number of pairs which sum upto target value.
Can I get the Answer key for this quiz?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.