Answered step by step
Verified Expert Solution
Question
1 Approved Answer
main.cpp 7 int countOfElements (const vector& listInput1, const vector int>& listInput int> countMap1; 8 unordered_map countMap2; 9 10 11 123 HH 12 13 14 15-
main.cpp 7 int countOfElements (const vector& listInput1, const vector int>& listInput int> countMap1; 8 unordered_map countMap2; 9 10 11 123 HH 12 13 14 15- 16 17 18 19 20 21 22 23 24 25 26 27- 28 29 30 31 32 33 34 35 36 37 38 57679 39 for (const auto& element : listInput1) { countMap1[element]++; } for (const auto& element : listInput2) { countMap2[element]++; } int count = 0; for (const auto& pair: countMap1) { int element = pair.first; int countInList1= pair.second; int countInList2 = countMap2 [element]; if (countInList2 == 0) { count += count InList1; } else { count += abs(countInList1 countInList2); } } for (const auto& pair: countMap2) { int element = pair.first; int countInList1 = countMap1[element]; int countInList2 = pair.second; if (countInList1 0) { count += countInList2; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started