Tilling Problem -II Question

There is a problem with my code. What cases have I missed ? Someone please help :\

@ap8730390 Bro its clearly mentioned that tile can be placed vertically or horizontally, so its clear that there will be two recursive call instead of one and you have just placed single recursive call Firstly.

Now let’s get to the question,

suppose there is a 4 * 3 floor, then you have a 1 * 3 tile.

  • Now if you place the tile horizontally then you have 3 * 3 floor left to tile.
    So you make a call for say tiling(n - 1) i.e n - 1 rows left to tile.

  • Now one vertical call is made by you in the code. So your work is to add the horizontal call.

That’s all bro! IF you have still doubt lemme know else mark it resolved.

I am still facing problems with regard to this recursive approach.

@ap8730390 If you have done maze path question, then why are you facing the problem its clearly mentioned that the tile can be placed horizontally as well as vertically. So there will be ofcourse two calls, one will be to place tile horizontally and one vertically.

Tile placed horizontally(one row is covered now recurse for remaining rows):-
countWays(n - 1, m)

Tile placed vertically if and only if :-
if(n - m >= 0) {
countWays(n - m, m)
}
Now where is the issue, try to visualize the case for 4*3.

What is the problem with my code. It is showing run time error. Please help!

Please help me with the tiling problem code. Anybody?

Maybe you’re not using dp for your code. Solving it with only recursion gives TLE

Otherwise, is my solution correct???

You can send your code here

Oh…Actually the problem is I don’t know when do we have to use mod :\