Use a table to avoid re-compute same pair of (i, j), also fill avoid re-compute 0 case.
Use a table to avoid re-compute same pair of (i, j), also fill avoid re-compute 0 case.

guandali/winter-camp,guandali/winter-camp