Advertisement
GokulDeep

NumberOfPaths

Mar 1st, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.21 KB | None | 0 0
  1. class Solution{
  2.    
  3.     long numberOfPaths(int M, int N) {
  4.          if ((M == 1) || (N  == 1)) {
  5.             return 1;
  6.         }
  7.  
  8.         return numberOfPaths(M - 1, N) + numberOfPaths(M, N - 1);
  9.     }
  10.    
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement