What if the question only allows output of distinct sequences, regardless of order, how does that change the solution? Still DP?
I think DP will still work, but right now I can only think an algorithm running in O(n*target) time and O(n^target) space. I don't know if there is anyway that can reduce the memory cause.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.