### KRISH_FOUSC's blog

By KRISH_FOUSC, history, 2 months ago,
• -8

 » 2 months ago, # | ← Rev. 3 →   0 Instead of calculating min 1’s and min 2’s required for each subarray . Calculate min 1’s and 2’s required for whole array then compare the subarray sum with min sum My submission : 248010905
 » 2 months ago, # |   0 There is a flaw in your logic. Consider 8 1 1 1 1 1 1 1 1, according to your logic, the corresponding array should have atleast a sum of 14 to make this one good. The correct answer is however 17.
 » 2 months ago, # |   0 The condition sum>=req in code is a necessary condition but not sufficient. The distribution of this sum matters consider the example 1,1,2,2 works fine with the logic but if we have 1,1,1,3 here though it has the same sum as before but the distribution of this sum is different, each of the ones must be incremented by atleast 1 so we need -3 from some element to maintain constant sum as per question but last element can't give 3 as it will become 0 after that.