[LeetCode]Count substrings that differ by one character

Revision en1, by vikalp14, 2022-06-28 17:25:50

I have read the solution for this problem but still have doubts about how the solution works.

Why doesnt dp[i][j] depend upon dp[i-1][j] and dp[i][j-1] why does dp[i][j] only depend on dp[i-1][j-1]

Solution link: https://leetcode.com/problems/count-substrings-that-differ-by-one-character/discuss/1523218/C%2B%2B-DP-(Detailed-Explanation-with-Examples)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English vikalp14 2022-06-28 17:35:14 7
en2 English vikalp14 2022-06-28 17:26:17 2 Tiny change: '[i][j-1]\nwhy does' -> '[i][j-1]\n\nwhy does'
en1 English vikalp14 2022-06-28 17:25:50 414 Initial revision (published)