public static int paths(int r, int c) {
if (r == 0 || c == 0) return 1;
return paths(r-1, c) + paths(r, c-1);
}
// Call: System.out.println(paths(2, 3));What is printed?
- A
20
- Bcheck_circle
10
- C
6
- D
5
Explanation
C(2+3, 2) = 10. Or compute: paths(2,3)=paths(1,3)+paths(2,2). paths(1,3)=4, paths(2,2)=6. Total 10.