We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c265d4 commit 579b6e3Copy full SHA for 579b6e3
Recursion/remove_duplicates.cpp
@@ -0,0 +1,27 @@
1
+#include <iostream>
2
+#include <string.h>
3
+using namespace std;
4
+void removeduplicates(char input[]){
5
+ if(input[0]=='\0'){
6
+ return ;//if it is empty string
7
+ }
8
+ if(input[0]==input[1]){//checking for consecutive duplicate
9
+ for(int i=0;input[i]!='\0';i++){
10
+ input[i]=input[i+1];//shift to left
11
12
+ removeduplicates(input);
13
+ }else{
14
+ removeduplicates(input+1);
15
16
+}
17
+
18
+int main() {
19
+ char input[1000];
20
+ cin.getline(input,1000);
21
22
+ cout<<input;
23
24
+/*Example
25
+aaaabbbbb
26
+O/p ab
27
+*/
0 commit comments