-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecallbook.h
65 lines (57 loc) · 1.11 KB
/
recallbook.h
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
56
57
58
59
60
61
62
63
64
65
#include "bits/stdc++.h"
using namespace std;
namespace rb {
// it splits numbers and makes vector of integers out of that
std::vector<int> splitnum(int n){
std::vector<int> v;
while(n){
int x = n % 10;
v.push_back(x);
n /= 10;
}
return v;
}
template <typename T>
vector<T> getVec(){
string s;
getline(cin, s);
stringstream ss(s);
vector<T> vec;
T ext;
while(ss>>ext){
vec.push_back(ext);
}
return vec;
}
int repeatations(vector<int> y, int num){
int count = 0;
for(int i=0; i < y.size(); i++){
if(num == y[i]) count++;
}
return count;
}
set<int> repeatingvals(vector<int> y){
set<int> reps;
for(int i=0; i < y.size(); i++){
int curval = y[i];
int count = 0;
for(int i=0; i < y.size(); i++){
if(curval== y[i]) count++;
}
if(count > 1) reps.insert(curval);
}
return reps;
}
set<int> nonrepeatingvals(vector<int> y){
set<int> reps;
for(int i=0; i < y.size(); i++){
int curval = y[i];
int count = 0;
for(int i=0; i < y.size(); i++){
if(curval== y[i]) count++;
}
if(count == 1) reps.insert(curval);
}
return reps;
}
}