Medium
Accuracy: 53.93%
Points: 4
You are standing on a point (x, y) and you want to go to the origin (0, 0) by taking steps either left or down i.e. from each point you are allowed to move either in (x-1, y) or (x, y-1). Find the number of paths from point to origin.
Input: x = 3, y = 0 Output: 1 Explanation: Path used was - (3,0) --> ( 2,0) --> (1,0) --> (0,0).We can see that there is no other path than this, so we return 1.
Input: x = 3, y = 6 Output: 84 Explanation: There are total 84 possible paths.
- Since this is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function ways() that takes integer x and y as parameters and returns the total number of paths from point(x,y) to the origin(0,0) % 1000000007.
O(x*y)
O(x*y)
0 ≤ x, y ≤ 500