Answer:
create a 2-dimensional array, let both rows represent the strings X and Y.
check for the common characters within a string and compare them with the other string value.
If there is a match, append it to the array rows.
After iterating over both strings for the substring, get the longest common substring for both strings and print.
Step-by-step explanation:
The algorithm should create an array that holds the substrings, then use the max function to get the largest or longest substring in the array.