edit distance modified version-bus station problem q

Edit Distance problem(leetcode)

problem: one dimension bus station, given a list of passangers: list = [0, 1,2, 4, 6, 7], they are all the passagers in One Dismension. And given a M as well, which means that the max time that the bus can stop, return in what stops for the car that makes the passager can pick up the bus in shortest distance.

logic: dp similar to min distance to multiple gas station.
we need to build stops to make the minimum distance.
解法: 求dp[i,j]表示前i个人(inclusive)和 j表示目前的公交站个数。
dp[i,j] = min(dp[k,j-1], min distance for people after k with one stop)

base: only one stop
optimal: median position