FunctionRacerProblemsRace

Count Sign Changes

EasyNumPyPython

The array has no zeros. Count how many times the sign flips from one item to the next, meaning a positive item followed by a negative one or a negative item followed by a positive one. Return an int.

Example 1

balance_changes [3,-1,-2,4,5,-6]
returns 3

The signs flip between 3 and -1, between -2 and 4, and between 5 and -6.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems