Min cost path dp

sir in this as i am going to choose the min cost path so i also want to store all element of min cost path in an array so what can i do for that

@Saurabh2771999
you come to dp[i][j] from either dp[i-1][j] or dp[i][j-1]
so you start backtracking from (n,m) and you go till (0,0) by comparing the up and left coordinates.