diff --git a/Basic of Programming/Arrays/Union of 2 array/q.md b/Basic of Programming/Arrays/Union of 2 array/q.md new file mode 100644 index 0000000..f074b89 --- /dev/null +++ b/Basic of Programming/Arrays/Union of 2 array/q.md @@ -0,0 +1,34 @@ +Link +
Given two arrays A and B of size N and M respectively. The task is to find union between these two arrays. +Union of the two arrays can be defined as the set containing distinct elements from both the arrays. If there are repetitions, then only one occurrence of element should be printed in union. + +Input: +The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consist of three lines. The first line of each test case contains two space separated integers N and M, where N is the size of array A and M is the size of array B. The second line of each test case contains N space separated integers denoting elements of array A. The third line of each test case contains M space separated integers denoting elements of array B. + +Output: +Correspoding to each test case, print the count of union elements of the two arrays. + +Expected Time Complexity: O(N + M). +Expected Auxiliary Space: O(N + M). + +Constraints: +1 ≤ T ≤ 100 +1 ≤ N, M ≤ 105 +1 ≤ A[i], B[i] < 105 + +Example: +Input: +2 +5 3 +1 2 3 4 5 +1 2 3 +6 2 +85 25 1 32 54 6 +85 2 +Output: +5 +7 + +Explanation: +Testcase 1: 1, 2, 3, 4 and 5 are the elements which comes in the union set of both arrays. +Testcase 2: 1 , 2 , 6 , 25 , 32 , 54 and 85 are the elements which comes in the union set of both arrays.\ No newline at end of file diff --git a/Basic of Programming/Arrays/Union of 2 array/sol.cpp b/Basic of Programming/Arrays/Union of 2 array/sol.cpp new file mode 100644 index 0000000..283005d --- /dev/null +++ b/Basic of Programming/Arrays/Union of 2 array/sol.cpp @@ -0,0 +1,25 @@ +#include
+Examples : + +Input: -12, 11, -13, -5, 6, -7, 5, -3, -6 +Output: -12 -13 -5 -7 -3 -6 11 6 5 +Note: Order of elements is not important here. +\ No newline at end of file diff --git a/Basic of Programming/Arrays/move negative no to left/sol.cpp b/Basic of Programming/Arrays/move negative no to left/sol.cpp new file mode 100644 index 0000000..d2b60be --- /dev/null +++ b/Basic of Programming/Arrays/move negative no to left/sol.cpp @@ -0,0 +1,70 @@ +//quick sort partion approch +#include