Percent Change
For each pair of neighboring days, return the percent change from the earlier price to the later one: (later - earlier) / earlier * 100. The result has one fewer item than prices. All prices are above 0.
Example 1
prices [100,110,99]
returns [10.0,-10.0]
100 to 110 is +10 percent; 110 to 99 is -10 percent.
Constraints
2 <= len(prices) <= 100- All prices are above 0
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Row RangesEasy
- Rows With a ZeroEasy
- Rows of WidthEasy
- Runner-Up per RowEasy
- Running Total per ColumnEasy
- Scale to Zero OneEasy
- Second LargestEasy
- Smallest PositiveEasy