Approach of recursion

i want to know if i’m using recursion correctly. Although all the testcases are passed but i’m not breaking the problem into similiar subproblems which is the basic idea of recursion.

#include
#include
using namespace std;
void myfunc(string str,int i)
{
int n=str.length();
if(i==n)
{
return;
}
if(str[i]==str[i+1])
{

}
else
{
	cout<<str[i];
}
myfunc(str,i+1);

}
int main() {
string str;
getline(cin,str);
myfunc(str,0);
return 0;
}

@Agam_virgo

i’m not breaking the problem into similiar subproblems which is the basic idea of recursion.

yes you are breaking them in to subproblems, when you do myfunc(i+1) this means you have solved the problem for s[0…i] and now the problem is for s[i+1 : ]

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.