Explain me This Solution

I am not getting this question and logic

have you tried out tilling problem part 1 ?


explanation: major part could be understood by the pictorial representation( hopefully)

for (int i = 1; i <= n; i++) { 
        if (i > m) 
            count[i] = count[i - 1] + count[i - m]; 
        else if (i < m) 
            count[i] = 1; 
        else
            count[i] = 2; 
    } 

so we have 1*m tile
placing horizontally reduces total size by 1
and placing vertically reduces by m
if ( i < m )
then it can be placed just in 1 way
else when i == m
2 possible adjustments ( horizontal and vertical are possible)

Please Explain recursive approach for this

the recursive case will give a tle here because of large constraints

This is not giving correct Output. Code Link : https://ide.codingblocks.com/s/232361 , According to your Logic

Thanks Got It , Just Added modulo 10^9 + 7. Thanks Chhavi bansal

1 Like

if doubt is resolved
please mark it as resolved

if you have further doubts regarding this problem you can ask

Hey @saurabhvit
sorry for the late reply.
Good to know u could do it on your own self

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.