When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

*get every possible combination of num sums, if num sums is == target, return true
wdym by every possible combination of num sums?
Learn how to use Dynamic Programming in this course for beginners. It can help you solve complex programming problems, such as those often seen in programming interview questions about data structures and algorithms.
This course was developed by Alvin Zablan from Coderbyte. Coderbyte is one of the top websites for technical interview prep and c...
the how sum one
every possible combination. Target minus that combination isnt < 0 thought
come on competitive chad, thats your thing
ah alr
you don't need it right?
alright
but then good luck copying elements from previous stacks return
i hate recursion with vector return values
ah alr
@crystal flicker
std::vector<int> HowSum(int t, std::vector<int> v)
{
std::vector<int>return_vec;
sort(v.begin(), v.end());
if (t < v[0])
return return_vec;
while (t!=0)
{
if (v.size() == 0)return std::vector<int>{};
for (int i = v.size() - 1; i >= 0; i--)
{
if (v[i] <= t)
{
t -= v[i];
return_vec.push_back(v[i]);
break;
}
else
v.erase(v.begin() + i);
}
}
return return_vec;
}
i think i did it
what is wrong?
there are no all the combinations
it might skip something
its only solvable with recursion
oh all combinations
then it shouldn't return a vector right?
it should
nah nah nah
just return the vector which sums up to target
thing is your once might skip some combinations that possibly can be an answer
oh wait
sry
so memo should contain all the vectors of solutions right?
alright but shouldn't HowSum be a vector<vector<int>> though?
yep and i need to return all possible solutions
but how can you do that in a vector<int>
you need to put all the solutions in a vector<vector<int>>
isn't this exactly what i wrote?
i don't get what is wrong
@crystal flicker
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. You can use !solved to close a post and mark it as solved.
!solved