Change Between Rows
Each row of grid is a snapshot of several sensors taken at one moment. Return a 2-D array that shows, for each pair of neighboring rows, the second row minus the first row. It has one fewer row than grid. Hint: np.diff with axis=0.
Example 1
grid [[1,5],[4,5],[2,9]]
returns [[3,0],[-2,4]]
Row 1 minus row 0 is [3, 0]; row 2 minus row 1 is [-2, 4].
Constraints
2 <= rows <= 101 <= columns <= 10
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Close EnoughEasy
- Closest to OriginEasy
- Closest to TargetEasy
- Column MaximumsEasy
- Column WinnersEasy
- Compound GrowthEasy
- Count BetweenEasy
- Count IncreasesEasy