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;
}