Here is my solution. Similar to other DP solutions but in Python.

OJ: Last executed input: "pcighfdjnbwfkohtklrecxnooxyipj", "npodkfchrfpxliocgtnykhxwjbojie"

I wrote a pure recursive Python solution and it is accepted but not DP solution.

Anyone knows why?

```
class Solution:
# @return a boolean
def isScramble(self, s1, s2):
if sorted(s1)!=sorted(s2):
return False
else:
n=len(s1)
dp=[[[s1[j]==s2[k] if i==0 else False for i in range(n)] for j in range(n)]for k in range(n)]
for L in range(2,n+1):
for i in range(n-L+1):
for j in range(n-L+1):
for m in range(1,L):
if dp[i][j][L-1]:
break
dp[i][j][L-1]=(dp[i][j][m-1] and dp[i+m][j+m][L-m-1]) or (dp[i+m][j][L-m-1] and dp[i][j+L-m][m-1])
return dp[0][0][n-1]
```