please help in optimizing the code.
Tiling Problem 2
heyy @dishask99 i see you are using recursion here but for given constraints it will give you time limit exceed, you have to store results in dp instead of recursive search
you can think it as:
for every row place tiles vertically and then if there is spcae in any column then place them horizontally.
you can use this in your code
dp[n+1]={0};
dp[0]=1;
for(ll i=1;i<=n;i++){
// Placing the tile vertically
dp[i]=dp[i-1];
// Placing the tile horizontally if there is space
if(i-m>=0)
dp[i]+=dp[i-m];
dp[i]%=mod;
}
then dp[n] will be your answer