@Dexter7620 Similar to this problem :https://leetcode.com/problems/remove-boxes/description/

Let dp[p][len][i] = the number of times we can remove t from a string W that is the concatenation of length p prefix of t and the substring of s of length len starting at i.

Actually the complexity is O(S^3T)