Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5704 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3523 |

@mantu_singh | 3510 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1156 |

@gurshehzadsingh | 676 |

@nithinreddy3210 | 642 |

@jha8768 | 577 |

@Run_for_life | 574 |

@divyagupta221100 | 557 |

@AkashLahoty | 553 |

@aayushdesai01 | 526 |

@riyakumaribkj | 526 |

@2017akku | 521 |

@amansinha74458 | 503 |

Complete Leaderboard |

Given a floor of size n x m and tiles of size 1 x m. The problem is to count the number of ways to tile the given floor using 1 x m tiles. A tile can either be placed horizontally or vertically.

Both n and m are positive integers and 2 < = m.

**Example 1 :**

Input:n = 2, m = 3Output:1Expanation:There is only one way to tile the given floor.

**Example 2 :**

**Input: **n = 4, m = 4
**Output: **2
**Explanation: **There is two ways to tile the
given floor.One way is to place 1 x 4 size
of tile vertically and another one is to
place them horizontally.

**Your Task:**

You don't need to read or print anything. Your task is to complete the function **countWays()** which takes n and m as input parameter and returns the total ways modulo **10 ^{9} + 7.**

**Expected Time Complexity: **O(n)

**Expected Space Complexity: **O(n)

**Constraints:**

1 <= n <= 100000

2 <= m <= 100000

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Count the number of ways to tile the floor of size n x m using 1 x m size tiles

...