FunctionRacerProblemsRace

Trend Signs

BeginnerArraysPython, JavaScript, TypeScript, Java, C++

values holds one measurement per day. For every pair of consecutive days, record 1 if the later value is bigger than the earlier one, -1 if it is smaller, and 0 if the two are equal.

Return the records in day order as a list with one item fewer than values. When values has fewer than two items, return an empty list.

Example 1

values [3,5,5,2]
returns [1,0,-1]

3 to 5 goes up, 5 to 5 stays level, 5 to 2 goes down.

Example 2

values [1,2,3]
returns [1,1]

Each day is higher than the one before it.

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 Arrays problems