The algorithm: Create a -D dp array of size m x n Initialize first row and first column to (only one way to reach each) For each cell (i, j) starting from (, ): - dp[i][j] = dp[i-][j] + dp[i][j-] Return dp[m-][n-] You can optimize to space by using a single row.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/dynamic-programming/unique-paths-solution
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████