helper
that takes the current target string and a memoization dictionary dp
.dp
, return the stored value to avoid recomputation.ans
to track the minimum number of stickers needed, starting with infinity.tar
.s
by subtracting the sticker's character frequencies from tar
.
c. Recursively call helper
with the new target string s
and update ans
with the minimum value.dp
for the current target string.dp
for the original target string.