(i, j int)
| 15 | } |
| 16 | |
| 17 | func dfs(i, j int) bool { |
| 18 | if i >= len(st1) && j >= len(st2) { |
| 19 | return true |
| 20 | } |
| 21 | |
| 22 | val, ok := cache[[2]int{i, j}] |
| 23 | |
| 24 | if ok { |
| 25 | return val |
| 26 | } |
| 27 | |
| 28 | if i < len(st1) && st1[i] == st3[i+j] && dfs(i+1, j) { |
| 29 | return true |
| 30 | } |
| 31 | if j < len(st2) && st2[j] == st3[i+j] && dfs(i, j+1) { |
| 32 | return true |
| 33 | } |
| 34 | |
| 35 | cache[[2]int{i, j}] = false |
| 36 | return false |
| 37 | } |