I prefer shorter code, so this one:
https://discuss.leetcode.com/topic/75448/memoization-c-solution
Please note: we don‘t want to be too greedy - desperately shrink the string from one side - no, that may not be a global optimal solution. So, we simply do DFS, putting char from hand into each slot - however, we always put same char, not new char, because we are trying to accumulate, not creating new one.
时间: 2024-10-13 19:43:30