Way to Home
Practice
5 (3 votes)
Medium
Problem
86% Success 475 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Pinaki wants to go to his home the map of city is a matrix of dimensions nxm. Initially pinaki is standing at (1,1) and his home is located at (n,m)

Pinaki can take moves of two types, He can move to right neighbouring cell or can move to the down neighbouring cell.also he does not want to take right moves consecutively while going to home. He wants to calculate the number of ways to reach home if he does not take two consecutive right steps.

As the number of ways may be large so print the answer modulo \(10^{9}\)+7(1000000007).

Input:

The only line conatins n and m dimensions of grid;

The Top left cell is (1,1) and bottom right cell is (n,m).

Output:

Print the number of ways to reach home by not taking two consecutive right steps.

Constraints:

1 ≤ n ≤ \(10^{3}\)

1 ≤ m ≤ \(10^{3}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
AlgorithmsApprovedMediumDynamic programming
Points:30
2 votes
Tags:
Medium
Points:30
5 votes
Tags:
Ad-HocAlgorithmsMediumDynamic ProgrammingDynamic programming