Given two arrays A and B of equal size N, the task is to find a vector containing only those elements which belong to exactly one array - either A or B - but not both. That is, if some element x appears in both A and B it should not be included in the output vector. Complete the implementation of "getVector(vectorA, vectorB, int N)" function. Example: Input:           1           3 5 7 1 3           2 4 6 7 8 Output:           3 5 1 3 2 4 6 8   The driver codes are attached in the images below.  DO NOT CHANGE THE PROVIDED DRIVER CODES AT ALL, LEAVE THEM EXACTLY THE SAME.  ONLY ADD CODE TO THE "getVector(vectorA, vectorB, int N)" FUNCTION

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Given two arrays A and B of equal size N, the task is to find a vector containing only those elements which belong to exactly one array - either A or B - but not both. That is, if some element x appears in both A and B it should not be included in the output vector. Complete the implementation of "getVector(vector<ll>A, vector<ll>B, int N)" function.

Example:

Input:

          1

          3 5 7 1 3

          2 4 6 7 8

Output:

          3 5 1 3 2 4 6 8

 

The driver codes are attached in the images below.  DO NOT CHANGE THE PROVIDED DRIVER CODES AT ALL, LEAVE THEM EXACTLY THE SAME.  ONLY ADD CODE TO THE "getVector(vector<ll>A, vector<ll>B, int N)" FUNCTION

 

// { Driver Code Starts
//Initial function template for C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//} Driver Code Ends
/User function template for C++
class Solution{
public:
//Function to return the output vector.
vector<il> getVector(vector<ll> A, vector<li> B, int N) {
llcode here
// { Driver Code Starts.
int main()
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
vector<ll> arr(n,0), brr(n,0);
// increase the count of elements in first array
for(ll i=0;i<n;i++)
cin >> arr[i);
Transcribed Image Text:// { Driver Code Starts //Initial function template for C++ #include<bits/stdc++.h> using namespace std; #define ll long long //} Driver Code Ends /User function template for C++ class Solution{ public: //Function to return the output vector. vector<il> getVector(vector<ll> A, vector<li> B, int N) { llcode here // { Driver Code Starts. int main() int t; cin>>t; while(t--) { int n; cin>>n; vector<ll> arr(n,0), brr(n,0); // increase the count of elements in first array for(ll i=0;i<n;i++) cin >> arr[i);
for (ll i=0;i<n;i++)
cin >> brr[i];
Solution ob;
for (auto x: ob.getVector(arr,brr,n))
cout << x << " ":
cout << endl;
return 0;
} //} Driver Code Ends
Transcribed Image Text:for (ll i=0;i<n;i++) cin >> brr[i]; Solution ob; for (auto x: ob.getVector(arr,brr,n)) cout << x << " ": cout << endl; return 0; } //} Driver Code Ends
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

This answer does not assist with the question, I am asking about the at() function.  I understand and can complete the for loop.

Solution
Bartleby Expert
SEE SOLUTION
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education