Here is the implementation for Edit Distance (CSES 1639). The code implements the recurrence relation directly. Each step corresponds to part of the formula. To verify your understanding, pick a small example and trace through the code by hand. Write down the value of each variable at each step. This builds intuition that helps when you face new problems. The three operations, insert, delete, replace, correspond to three transitions in the DP.
Time complexity: .
Space complexity: for the DP table.