not getting any outpput
Duplicate character recursion
in this you have taken char array can we take string of cpp?
yes u can take string
string is easy to understand and manipulation is simpler
what char array can do ,that can be also done by by cpp string na?
#include<bits/stdc++.h>
using namespace std;
void replaceduplicates(string arr,int i,int n){
if(n==0){
cout<<arr;
return;
}
if(i==n){
cout<<arr;
return;
}
else if(arr[i]==arr[i+1]){
// hel*loop
for(int k=n;k>i;k--){
arr[k+1]=arr[k];
}
arr[i+1]='*';
replaceduplicates(arr,i+2,n);
}
else{
replaceduplicates(arr,i+1,n);
}
}
int main() {
string arr;
cin>>arr;
replaceduplicates(arr,0,arr.length()-1);
return 0;
}
pls check I have done this by my own but not gettinig last index char in output
share code in cb ide
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.