I solved the rec case but cannot figure out the base case
Cant understand the base case
hello @king-slayer97
if n < m then we will have only one way of arraning the tiles.
so put if(n<m) return 1; as one of ur base case
your solution has exponential time complexity thats why it is giving tle.
use dynamic programming to optimise it.
becuase of dp array size it is giving run error.
why r u considering m as ur dp state, it is always constant.
use 1dp where dp[i]= ways of arranging i X M matrix.
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.