Maximize Toys Geeksforgeeks

problem

can anybody tell why it shows runtime error for DP solution.

solved using the strategy of 0-1 knapsack.

while solution using heap got AC.

Why do either of those complex things, just sort the array

But anyway, run your code on any maxtest (max constraints) and you’ll get SIGSEGV because your array is too big, you have to make it a global array

1 Like