Your question is Coding: Sliding Window Function. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Datadog Metrics processing can group sequential three-dimensional coordinate values into fixed-size windows. Given an ordered sequence of 3D points and a window size k, return the coordinate-wise sum for every contiguous window of exactly k points.
The first output represents points 0 through k - 1. Each following window moves one position right, so update the previous sum by subtracting the point that leaves and adding the point that enters.
Implement sliding_coordinate_sums(points, k).
points: a list of points, where each point is a list of exactly three integers [x, y, z].k: a positive integer window size.[sum_x, sum_y, sum_z] for one contiguous window.k is greater than the number of points.def sliding_coordinate_sums(points, k):