【Google真题】 A binary array 100%AC python
【Google真题】 A binary array 100%AC python
You are given a binary array A. A binary array contains only 0 and1 (1-based indexing). You can perform the following operation atmost one times.
Change an array element from 1 to 0.
You are required to maximize the number of subarrays thatcontain at least one 0 and find the number of such subarrays thatcontain at least one 0.
Input format:
The first line contains T’ denoting the number of test cases
The first line of each test case contains N denoting the size of the binary array.
The next line of each test case contains N space-separatedintegers denoting array elements.
Output format:
Print the maximum number of subarrays which will contain at leastone 0 in a new line.