Difficulty
Easy
Language
Python
Solution 1 - Brute Force
Iterate through every pair of numbers using two nested loops. For each pair, check if they sum to the target. Return the indices when a match is found.
Solution 2 - Brute Force using enumerate()
Same brute force logic, but uses Python's enumerate() for cleaner index tracking instead of range(len(...)).
Solution 1 - Linear Scan
Iterate through the array and count the number of positive and negative integers separately. Return the maximum of the two counts. Zero is neither positive nor negative, so it is skipped.
Solution 2 - Binary Search
Since the array is sorted in non-decreasing order, use binary search to find the count of negatives (index of first element >= 0) and the count of positives (n minus the index of first element > 0). This leverages bisect_left and bisect_right for efficient boundary detection.