Count 1's in a sorted binary array
Given a binary array arr[] of size N, which is sorted in non-increasing order, count the number of 1's in it. Examples: Input: arr[] = {1, 1, 0, 0, 0, 0, 0}Output: 2 Input: arr[] = {1, 1, 1, 1, 1, 1, 1}Output: 7 Input: arr[] = {0, 0, 0, 0, 0, 0, 0}Output: 0 Naive approach: A simple solution is to li