LC 3797 - Count Routes to Climb a Rectangular Grid
Approach This is a DP like problem, and I find that we can think that when we want to calculate ans[i][j] on row i from row i-1, we just aggregate the previous row’s ans within the l2 distance of d and we get the answer. But the problem stats that we can jump in the same row in range d, so I tried to buffer the row i-1 aggregated results to jump, and then try to sum up all the jump within distance d. Originally I think that for the index j itself we need to count twice, since we can jump from upper row, or jump from upper row and jump to itself again. However, from the testcase it seems that jump to itself is invalid. Under this circumstance we just add up all the jumps within range d and we got the answer for row i. ...