2021-9: In the Long Run

Write code that:

has an argument that is a numeric vector of 2 or more elements representing daily prices of a stock.

returns an integer singleton that represents the highest number of consecutive days where the price increased, decreased, or remained the same, relative to the previous day.

Examples

Implementation

You can also run the tests via ⌘/shift + enter