aman_naughty's blog

By aman_naughty, history, 5 years ago, In English

Problem link: link

My code

Spoiler

We have 2 choices for each element either + or — I am considering both the choices and then picking the optimal one. In the code the dp[i].first = the minimum number of sign inversions dp[i].second = the optimal sum we achieve by either inverting this one or not;

It fails on array 10 4 3 2 1

Can someone point out why my aaproach is wrong?

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?