Tiling Problem using Recursion

I have written the program for this however I am unable to pass the test cases.

if(n<m){
	return 1;
} 
if(n==m){
    return 2;
}
return tiles(n-1,m) + tiles(n-m,m); 

The recursive case is a bit unclear to me yet.

hello @ritkumar

if u have NxM matrix then if u place of tile horizontally then u will end up to (N-1 X M)

if u place M tiles vetically then u will end up to (N-M X M)

there is no other way of arranging tiles as per the given dimension.

hence

this recurrence relation
count of ways we 1 tile is put horizontally + count of ways when M is is put vertically

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.