sir, I tried solving the Tilling Problem-II problem but I couldn’t solve it. So I tried looking at the solution but, the solution is not in Java and I couldn’t understand it. I request you to provide the solution(code) in java along with algo if possible.
Solution for Tilling Problem-II in Java
I am writing the algo here. You’d have to attempt the code by yourself.
For any length n * m, imagine what possible options do we have for the last tile. Either we can pave it using a vertical tile i.e. , now the problem transforms to solving for length n - 1. Or we could put m horizontal tiles and now the problem transforms to solving for length n - m. Thus f(n) = f(n - 1) + f(n - m) . First attempt it using recursion, then memoize it and use Modulus and it should work.
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.