More Positives or Negatives
In a sorted list, negative numbers appear on the left, positive numbers on the right, and zeroes in the middle. Given an ascending sorted list nums, count the strictly negative values and the strictly positive values. Return whichever count is larger.
Примеры
Ввод
[-2, -1, -1, 1, 2, 3]Вывод
3Ввод
[-3, -2, -1, 0, 0, 1, 2]Вывод
3Ввод
[5, 20, 66, 1314]Вывод
4Нужно реализовать
def maximum_count(nums: list[int]) -> int:
Теги
arraybinary-searchmath
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
[-2,-1,-1,1,2,3]Expected
32
Input
[-3,-2,-1,0,0,1,2]Expected
33
Input
[5,20,66,1314]Expected
44
Input
[0,0,0]Expected
05
Input
[-1,-1,-1]Expected
36
Input
[3,2,1,-1,-1,-2]Expected
3Focus radio
Paused · SomaFM · Fluid