Created
December 4, 2019 12:08
-
-
Save mk6619/a7529bf23319ef0f56139153c5f05026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| int main() { | |
| //code | |
| int testCases; | |
| cin>>testCases; | |
| for(int i = 0 ; i < testCases; i++) { | |
| int n,m; | |
| cin>>n; | |
| cin>>m; | |
| int arr[n],arr_m[m]; | |
| for(int j =0 ; j < n ; j++) { | |
| cin>>arr[j]; | |
| } | |
| for(int j =0 ; j < m ; j++) { | |
| cin>>arr_m[j]; | |
| } | |
| int left = 0, right = 0; | |
| while(left < n && right < m) { | |
| if(arr[left] < arr_m[right]) { | |
| cout << arr[left]<<" "; | |
| left++; | |
| } else { | |
| cout << arr_m[right]<<" "; | |
| right++; | |
| } | |
| } | |
| if(left < n) { | |
| for(int j = left ; j < n; j++) { | |
| cout<<arr[j]<<" "; | |
| } | |
| } | |
| if(right < m) { | |
| for(int j = right ; j < m; j++) { | |
| cout<<arr_m[j]<<" "; | |
| } | |
| } | |
| cout << "\n"; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment