Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Print reverese string non repeated chars
//Title of this code #include <iostream> #include <string> using namespace std; void setFlag(char c, int& n) { int i = c - 'a'; n |= 1 << i; } bool getFlag(char c, int n) { int i = c - 'a'; return n & (1 << i); } void printReverseString(const string& s) { int n = 0; for (int i = s.length() - 1; i >= 0; --i) { if (!getFlag(s[i], n)) { cout << s[i]; setFlag(s[i], n); } } cout << endl; } int main() { printReverseString("abbcaad"); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
p30
sdfsdf
maya angelou
ThreadContext
Binary Search
Pollard Rho Brent Integer Factorization - 11476 - Factorizing Larget Integers
czekolada
Nieparzyste w macierzy
Graph DFS
Best buy/sell day in stock
stackse - search stackoverflow differently
Please log in to post a comment.