Doubt in tilling problem

can you help me with the code please

hi @adarshsingh2k i see you passed all the test cases, what do you need help with?

i used dp to sole it can you help me with the code for recurssion

@adarshsingh2k have you copied this code from somewhere?

yeah i took refernce from other platforms

@adarshsingh2k dont copy the code blindly. The code that you submitted is using recursion with memoization, ie top-down DP.

can you just tell me simple approach and base case

for 2*3 we have two ways i.e. either horizontally or vertically

@adarshsingh2k
does this mean you did not even read the code you submitted?

The recurrance relation is:
f(n) = f(n-1) + f(n-m);

Read the code once and see the base conditions used there.

hey i read code and editorial both the reason i asked bcoz i am not able to get the base condition from code

@adarshsingh2k
image

These are the base conditions:

if (n < 1) return 0;
if (n == m) return 2;
if (n < m) return 1;

Recursive case:

return f(n-1, m) + f(n-m, m);

@adarshsingh2k the code will give TLE without memoization, this is why it must be used.

what is memoization can you tell please

@adarshsingh2k it is a technique used to remember the answers that have already been calculated to avoid calculating the same thing again and again. I would recommend you to watch the initial lectures on DP to get a better idea.

is there any other way to solve it

@adarshsingh2k no it can be solved by DP only

is it explained in dp section

hi @adarshsingh2k memoization (top-down DP) is explained in the DP section.

i am asking about tilling problem

hey did you delete my messages