Count the number of ways to tile the floor of size n x m using 1 x m size tiles | function to count the total number of ways ; table to store values of subproblems ; Fill the table upto value n ; recurrence relation ; base cases and i = m = 1 ; i = = m ; required number of ways ; Driver Code
function countWays ( n , m ) { let count = new Array ( n + 1 ) ; count [ 0 ] = 0 ; let i ; for ( i = 1 ; i <= n ; i ++ ) { if ( i > m ) count [ i ] = count [ i - 1 ] + count [ i - m ] ; else if ( i < m i == 1 ) count [ i ] = 1 ; else count [ i ] = 2 ; } return count [ n ] ; } let n = 7 ; let m = 4 ; document . write ( " " + countWays ( n , m ) ) ;