作者:
sixB (6B)
2024-12-30 02:30:031639.
破防 大家都去跨年開趴了嗎
這題竟然都沒人發
hard難得好寫的dp欸==
先算frequency
然後dp一個一個推
開2d的話j就不用倒著計算了
記得要mod
using ll = long long;
class Solution {
public:
ll mod = 1e9 + 7;
int numWays(vector<string>& words, string target) {
int len = words[0].length();
int tlen = target.length();
vector<vector<ll>> ch(len, vector<ll>(26, 0));
for(int i = 0; i < len; i++){
for(auto& s: words){
ch[i][s[i]-'a']++;
}
}
ll res = 0;
vector<ll> dp(tlen, 0);
for(int i = 0; i < len; i++){
for(int j = min(i, tlen-1); j > 0; j