Skip to content

Commit 03aeae0

Browse files
authored
Removing Duplicate from String
1 parent f891f1c commit 03aeae0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

removeduplicate.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
using namespace std;
4+
string rmvdup(string s)
5+
{
6+
if (s.size() == 0)
7+
return "";
8+
char str = s[0];
9+
string st = rmvdup(s.substr(1));
10+
if (str == st[0])
11+
return st;
12+
return (str + st);
13+
}
14+
int main(int argc, char const *argv[])
15+
{
16+
17+
cout << rmvdup("aaaabbbbbcccddeeeeef") << endl;
18+
return 0;
19+
}

0 commit comments

Comments
 (0)