Maximum Count of Positive Integer and Negative Integer
A easy-tier problem at 74% community acceptance, tagged with Array, Binary Search, Counting. Reported in interviews at ShareChat and 0 others.
You've got an array with positive integers, negative integers, and zeros mixed together. The ask is simple on the surface: count which group has more elements, positives or negatives. ShareChat has asked this. It's an easy problem with a 74% acceptance rate, which means roughly one in four candidates still misses something. The trap is overthinking it or picking the wrong approach when the array is sorted. If this hits your live OA and you freeze on the optimal path, StealthCoder surfaces the working solution in seconds, invisible to the proctor.
Companies that ask "Maximum Count of Positive Integer and Negative Integer"
Maximum Count of Positive Integer and Negative Integer is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe naive approach is a linear scan: walk the array once, count positives and negatives, return the max. That's O(n) time and passes. But the problem states the array is sorted. That's your signal. Binary search can find the boundary between negatives and positives in O(log n) time, which is the pattern they're testing. Many candidates see 'easy' and 'sorted array' and still write the linear scan because they don't connect the Array, Binary Search, and Counting topics. The trick is finding where negatives end and positives begin using two binary searches or one search for the leftmost positive. If you blank on the binary search edge cases during the assessment, StealthCoder handles the boundary logic and delivers a clean solution.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum Count of Positive Integer and Negative Integer recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Count of Positive Integer and Negative Integer interview FAQ
Is this really about binary search, or is linear scan enough?+
Linear scan works and passes. But the problem lists Binary Search as a topic, which signals the expected approach. If the array is large, O(log n) beats O(n). For an easy problem, they're teaching you to recognize sorted arrays as a binary search opportunity, not just a counting drill.
What's the main pitfall candidates hit on this one?+
Overthinking or ignoring the sorted array hint. Some scan the whole array when they could find boundaries in log time. Others get tripped up on edge cases like all negatives, all positives, or mixed with zeros. Zero doesn't count toward either group.
How does this relate to typical interview patterns?+
It's testing foundational skills: array traversal, counting, and binary search awareness. Easy problems on sorted arrays almost always want you to recognize the binary search opportunity. ShareChat's ask signals they value optimization thinking, not just correctness.
Do I need to handle edge cases like all zeros or all one sign?+
Yes. If the array is all zeros, both counts are zero, return zero. If all negative or all positive, the other count is zero. Your solution should handle these cleanly without crashing or returning nonsense.
How much time should I spend on this in a real interview?+
This is warm-up territory. Write the linear scan first (two to three minutes), get it working, then optimize to binary search if you feel confident. Don't get stuck optimizing. An easy problem done in five minutes beats a half-baked optimal solution.
Want the actual problem statement? View "Maximum Count of Positive Integer and Negative Integer" on LeetCode →