joining two vectors in c 2b 2b

Solutions on MaxInterview for joining two vectors in c 2b 2b by the best coders in the world

showing results for - "joining two vectors in c 2b 2b"
Juan José
16 Mar 2019
1// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
2vector<int> AB;
3AB.reserve(A.size() + B.size()); // preallocate memory
4AB.insert(AB.end(), A.begin(), A.end());
5AB.insert(AB.end(), B.begin(), B.end());
6//eg : A = {4, 1}, B = {2, 5}
7//after the 2 insert operations, AB = {4, 1, 2, 5}