2
def numWays(self, words: List[str], target: str) -> int:4
m, n = len(words[0]), len(target)5
charAtIndexCnt = [[0] * m for _ in range(128)]7
for i, c in enumerate(word):8
charAtIndexCnt[ord(c)][10
] += 1 # Count the number of character `c` at index `i` of all words14
if i == n: # Formed a valid target16
if k == m: # Reached to length of words[x] but don't found any result19
ans = dp(k + 1, i) # Skip k_th index of words21
charAtIndexCnt[ord(c)][k] > 022
): # Take k_th index of words if found character `c` at index k_th23
ans += dp(k + 1, i + 1) * charAtIndexCnt[ord(c)][k]