Concept Flow - Longest Common Substring
Start with two strings
Create 2D table of size (len(s1)+1) x (len(s2)+1)
Initialize all cells to 0
For each character in s1 (i)
For each character in s2 (j)
If s1[i-1
Yes
Set table[i
Update max length and position if needed
No
Set table[i
After filling table, extract substring from s1 using max length and position
Return longest common substring
We compare characters of two strings using a 2D table to find the longest matching substring by building lengths of matching suffixes step-by-step.
