原题题目
代码实现(首刷小部分看解大部分自解)
class Solution {
public:
int minStickers(vector<string>& stickers, string target) {
int strl = target.size(),temp;
vector<int> dp (1<<strl,-1);
dp[0] = 0;
for(int i=0;i< 1<<strl;i++)
{
if(dp[i] == -1)
continue;
for(string str:stickers)
{
temp = i;
for(char chr:str)
{
for(int j=0;j<strl;j++)
{
if(chr != target[j] || temp & (1<<j))
continue;
temp |= 1<<j;
if(dp[temp] == -1) dp[temp] = dp[i] + 1;
else dp[temp] = fmin(dp[temp],dp[i] + 1);
break;
}
}
}
}
return dp[(1<<strl)-1];
}
};