Back to problems

Compute suffix sums over waypoints

Algorithm · Tesla · Medium

Given a batch of 2D trajectories points with shape [B, N, 2], where points[b][i] stores the (x, y) coordinates of waypoint i in trajectory b, return a floating-point array rem with shape [B, N]. For each trajectory b, rem[b][i] is the remaining path length from waypoint i through the final waypoint. Consecutive waypoints are connected by straight line segments. Write points[b][j] = (x_j, y_j). Then $$ rem[b][i] = \sum_{j=i}^{N-2} \sqrt{(x_{j+1} - x_j)^2 + (y_{j+1} - y_j)^2}.…

Checking your access…