Using only recursion C++


#1
bool fun(string A, int index1,int index2,int len){
    
    if(len>=2) {return true;}
    
    if(index1>=A.size()) return false; //if we traversed whole string
    
    if(index2 >= A.size()) return fun(A,index1+1,index1+2,len); //if pointer2 get to last pos
    
    if(A[index1] == A[index2]) return fun(A,index1+1,index2+1,len+1);//if we found equal char
    
    return fun(A,index1,index2+1,len); // else increase pointer2
    
}
int Solution::anytwo(string A) {
    return (fun(A,0,1,0)) ? 1 : 0;
}

//There is no overlap then why use DP ?