contains category wise problems(data structures, competitive) of popular platforms.
View the Project on GitHub mayankdutta/category-wise-problems
Tags: prefix-sum kadane
note that to calculate the maximum ans.
let say we are to choose positive no.s and they are in following order.
startng from 'S' and ending at 'E'
PPPP NNNNN PPPP
-->E S---->
indirectly we want to have all 'P' OR we can say we want all values but not 'N'
therefore why not just calculate value of 'N' then subtract from overall 'SUM'.
Algorithm
PPPP NNNNN PPP
invert the array
NNNN PPPPP NNN
apply kadane
get MAX VALUE
it is MIN VALUE(in disguise)
sum - MIN VALUE