int waysTop
= x == 0 ? 0 : computeNumberOfWaysToXY(x - 1, y, numberOfWays);
int waysLeft
= x == 0 ? 0 : computeNumberOfWaysToXY(x, y - 1, numberOfWays);
I can’t make sense out of the bold part. Doesn’t seem needed at all.
int waysTop
= x == 0 ? 0 : computeNumberOfWaysToXY(x - 1, y, numberOfWays);
int waysLeft
= x == 0 ? 0 : computeNumberOfWaysToXY(x, y - 1, numberOfWays);
I can’t make sense out of the bold part. Doesn’t seem needed at all.
Hi @ray,
We do need that as we are processing entries of (x, 0) and (0, y) where x and y are not 0. The special case in the code only handles the case (0, 0).
Isn’t the special case handling code doing if (x==0 || y==0)? That should handle all (x,0) and (0,y) cases right?
The special case only handles (x == 0 && y == 0) (by returning 1), and we can add another special case by handling (x == 0 || y == 0) but we did not do that.