Time Limit Exceed Problem

Could You Please Look Through the COde mine is going ttl
#include <bits/stdc++.h>
using namespace std;

int dp[1005][1005][12][2];

int string_game(string s1,string s2,int i,int j,int k,int c,int len1,int len2)
{
if(k==0)
return 0;

if(i==len1 || j==len2)
{   
    if(k==0)
        return 0;
    else
        return INT_MIN;
}

if(dp[i][j][k][c]!=-1)
        return dp[i][j][k][c];


    dp[i][j][k][c]=max(string_game(s1,s2,i,j+1,k-c,0,len1,len2),max(string_game(s1,s2,i+1,j,k-c,0,len1,len2),max(s1[i]==s2[j]?1+string_game(s1,s2,i+1,j+1,k,1,len1,len2):0,s1[i]==s2[j]?1+string_game(s1,s2,i+1,j+1,k-1,0,len1,len2):0)));
    return dp[i][j][k][c];

}
int main()
{
int n,m,k;
cin>>n>>m>>k;

string s1;
string s2;
cin>>s1;
cin>>s2;
memset(dp,-1,sizeof(dp));
//cout<<max(string_game(s1,s2,0,0,k,1,n,m),string_game(s1,s2,0,0,k,0,n,m))<<endl;
cout<<string_game(s1,s2,0,0,k,0,n,m)<<endl;

return 0;
}

@vikram.keswani108,
Please use CodingBlocks IDE for sharing codes, don’t just copy/paste here.
You can check whether or not your recursion is correct by comparing it with this code.
Please use global containers, specially in recursive functions, else each time the recursive function is called, so will be the copy constructor and O(n) operation will happen. Rather just make everything global.

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.