New answers tagged

2 votes
Accepted

Construct an objective function that favors the sorted permutation

I don't understand why you seem to want that computing the best value of the objective function must require sorting the array. In optimization problems (look for example at the class $\mathsf{NPO}$), ...
  • 24.5k
6 votes

Why does the order of the nested loops matter when solving the Coin Change problem?

Why is the working solution correct? First things first. Important things first. Let us understand why the working solution is correct first instead of finding where the wrong solution goes wrong. ...
  • 35.5k
10 votes
Accepted

Why does the order of the nested loops matter when solving the Coin Change problem?

In the second solution you are overcounting the number of combinations. In fact you are counting the of ways to choose an ordered list of coins that sums to sum. ...
  • 24.5k

Top 50 recent answers are included