-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMapOfVector.cpp
More file actions
40 lines (33 loc) · 844 Bytes
/
MapOfVector.cpp
File metadata and controls
40 lines (33 loc) · 844 Bytes
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
// Taken from geeks for geeks
#include <bits/stdc++.h>
using namespace std;
map<vector<int>, int> vis;
// Print True if vector is visited
// or False if not visited
void CheckVisited(vector<int> data)
{
if (vis.find(data) != vis.end()) {
cout << "True" << endl;
}
else {
cout << "False" << endl;
}
}
// Driver code
int main()
{
// Initializing some vectors
vector<int> data_1{ 10, 20, 30, 40 };
vector<int> data_2{ 5, 10, 15 };
// Making some vectors as visited
vis[data_1] = 1
vis[data_2] = 1;
vis[data_3] = 1;
// checking if these vectors are
// visited or not
vector<int> check_1 = { 5, 10, 15 };
vector<int> check_2 = { 2, 4, 6, 8, 10, 12 };
CheckVisited(check_0);
CheckVisited(check_1);
return 0;
}