sir please check the code
Tiling problem 2
Your solution complexity is exponentially and there are overlapping subproblem. This is a Dp problem. Same your recursive states either top down or bottom up approach.
For hint this is iterative method
vectordp(n + 1, 0);
dp[0] = 1;
for (ll i = 1; i <= n; i++) {
// Placing the tile vertically
dp[i] = dp[i - 1];
// Placint the tile horizontally if there is space
dp[i] += ((i - m) >= 0) ? dp[i - m] : 0;
dp[i] %= mod;
}
cout << dp[n] << endl;
If you not able to understand this code, google the question. This is a standard question.
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.