Question: Using C++ write a program to find the kth smallest element in the concatenation of two vectors A and B, given that both vectors are

Using C++ write a program to find the kth smallest element in the concatenation of two vectors A and B, given that both vectors are sorted in decreasing order. You can assume 1 k A.size() + B.size(). The function declaration is given below.

int findKthSmallest(vector A, vector B, int k);

For example, for A = [4, 2, 1] and B = [7, 5, 2, -3], the 2nd smallest element in the concatenation of A and B is 1.

Your job is to implement a findKthSmallest as a single function as described above.

Step by Step Solution

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