Passes all cases without DP, java recursive solution

public int solve(String A, String B, String C, int m, int n , int k){

    if(m==0 && k==0 && n==0){return 1;}
    if(m==0 && n==0 && k!=0){return 0;}
    
    
    if(m>0 && n>0&&A.charAt(m-1) == C.charAt(k-1) && B.charAt(n-1) == C.charAt(k-1)){
    return Math.max(solve(A,B,C,m-1,n,k-1),solve(A,B,C,m,n-1,k-1));
}else if(m>0 &&A.charAt(m-1) == C.charAt(k-1)){
    return solve(A,B,C,m-1,n,k-1);
}else if(n>0 && B.charAt(n-1) == C.charAt(k-1)){
    return solve(A,B,C,m,n-1,k-1);
}else{
    return 0;
}
Click here to start solving coding interview questions