Interviewbit problem help

Правка en1, от aman_naughty, 2019-07-18 18:50:23

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?

Теги #dp, #interview, #beginner, #help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский aman_naughty 2019-07-18 18:50:23 1183 Initial revision (published)