- Arrays, Binary Search, Searching

Find the maximum among the count of positive or negative integers in the array

Given a sorted array arr[] consisting of N integers, the task is to find the maximum among the count of positive or negative integers in the array arr[].Examples:Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.Input: arr[] = {-9, -7, -4, 1, 5, 8, 9}Output: 4Explanation:The count of positive numbers is 4 and the count of negative numbers is 3. So, the maximum among 4, 3 is 4. Therefore, print 4.Input: arr[] = {-8, -6, 10, 15}Output: 2Approach: The given problem can be solved by using Binary Search, the idea is to find the first index whose value is positive and then print the maximum of idx and (N – idx) as the result. Follow the steps below to solve the given problem:Initialize two variables, say low as 0 and high as (N – 1).Perform the Binary Search on the given array arr[] by iterating until low