-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymetric Encoding.cpp
More file actions
79 lines (72 loc) · 1.65 KB
/
Copy pathSymetric Encoding.cpp
File metadata and controls
79 lines (72 loc) · 1.65 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
//#include <bits/stdc++.h>
//using namespace std;
//
//int main()
//{
// int t;
// cin>>t;
// while(t--)
// {
// int n;
// cin>>n;
//
// string str ;
// cin>>str;
//
// vector<char> v;
//
// map<char,char>vp;
// for (char c : str)
// {
// if (find(v.begin(), v.end(), c) == v.end())
// {
// v.push_back(c);
// }
// }
// int sz=v.size();
// sort(v.begin(),v.end());
// for(int i=0; i<v.size(); i++)
// {
// vp[v[i]]=v[sz-i-1];
// }
//
// for(int i=0; i<n; i++)
// {
// cout<<vp[str[i]];
// }
// cout<<endl;
// }
//
//
// return 0;
//}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
// Function to remove duplicates from a vector
//void removeDuplicates(vector<char> &vec) {
// sort(vec.begin(), vec.end()); // Sort the vector
// vec.erase(unique(vec.begin(), vec.end()), vec.end()); // Remove duplicates
//}
int main() {
string str ;
cin>>str;
vector<char> uniqueChars;
// Extract unique characters from the string
for (char c : str) {
if (find(uniqueChars.begin(), uniqueChars.end(), c) == uniqueChars.end()) {
uniqueChars.push_back(c);
}
}
// Optionally, remove duplicates from the vector
//removeDuplicates(uniqueChars);
// Print the unique characters
cout << "Unique characters: ";
for (char c : uniqueChars) {
cout << c << " ";
}
cout << endl;
return 0;
}