Gary has an array of N coins some have head side up and others have the tail side up. Now Gary wants to flip exactly one interval of coins (i.e. continuous subarray) so that he can get maximum number of head side up coins.
Return the maximum number of head side up coins Gary can get after flipping exactly one interval of coins.
Note : Assume input is 1 - indexed based i.e. indexing in array starts from 1 instead of 0.
Input Format :
Line 1 : An integer N denoting size of array Line 2 : Array elements, 0's and 1's where 1 denotes coin with head side up and 0 denotes coin with tail side up
Output Format :
Required maximum number
1<= N <=1000
Sample Input :
5 0 1 0 1 0
Sample Output :
Login to submit your solution