InterviewBit Grid Unique Path
by ne on 2022-02-16 under Algo/DS/Problems tagged with interviewbit
public class Solution {
public int uniquePaths(int x, int y) {
if(x==y && x==1) return 1;
return rec(x-1,y-1);
}
private int rec(int toX, int toY){
if(toX==0 && toY>0) return 1;
if(toY==0 && toX>0) return 1;
return rec(toX-1,toY) + rec(toX,toY-1);
}
}