Ancestry interview question

Dynamic programming problem related to strings