I have to make a dynamic programming algorithm that solve this problem : Given sequence S and T, find a sequence X and Y such that S and T belong to the shuffle of X and Y.
Sequence S and T are given with each having length n . We want to find a sequence X and a sequence Y each of length k an l such that S and T belong to the shuffle product of X and Y. Knowing that (k+l = n)
How to I go about solving this using dynamic programming. I'm interested in knowing what could be the policy for using past results. As of now I have no idea.
Can someone do an example with S = GTACA and T = AGCAT Let's assume that my table looks like this:
We want the green cell to provide sequence X and Y or provide nothing (In the case X and Y don't exist)
I have noticed that in many dynamic programming problems the past solution for building the current one is selected from either the cell at the left (red) or top (yellow) or diagonal (blue) of the current cell (outline in green). I still struggle to know how to select given my specific problem.
UPDATE
When I try to find the longest common subsequence as suggested by the answer below I get AGCA following this (from the wikipedia article suggested below.)

My dynamic programming table looks like this:

If I made a mistake please tell me where so I can correct it.

