-
Notifications
You must be signed in to change notification settings - Fork 1
/
Check if two arrays are equal or not.cpp
55 lines (46 loc) · 1.14 KB
/
Check if two arrays are equal or not.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//{ 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 check if two arrays are equal or not.
bool check(vector<ll> A, vector<ll> B, int N) {
//code here
sort(A.begin(), A.end());
sort(B.begin(), B.end());
for(int i =0; i < A.size(); i++)
{
if(A[i] != B[i])
return false;
}
return true;
}
};
//{ 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];
// iterate through another array
// and decrement the count of elements
// in the map in which frequency of elements
// is stored for first array
for(ll i=0;i<n;i++)
cin >> brr[i];
Solution ob;
cout << ob.check(arr,brr,n) << "\n";
}
return 0;
}
// } Driver Code Ends