These problems mix the two table shapes from this unit and a few that need no table at all. Before you code, decide which shape fits: one index per prefix (splitting one string), two indexes for two prefixes (comparing two strings), or start and end for a span (choices that split the input in the middle).
Then say what one cell means, which cells it reads, and which order fills them so those cells are ready. Two problems have cheaper answers than a full table: look for them before you build one.
Pick the table shape before writing code.