Meeting of Points Moving Toward Initial Successors
Problem statement
Determine whether all the points occupy the same position at one common time during their movement.
For this exercise, the array order defines a cycle. Let P[i] be point i’s initial two-dimensional position, and let its fixed destination be the initial position P[(i+1) mod n]. All points begin at time 0 and complete their own straight-line segment at time 1, using constant velocity on that segment:
position[i](t) = (1-t) * P[i] + t * P[(i+1) mod n], for real 0 <= t <= 1.
Return true if one time t makes every position equal; otherwise return false. Coincident starting positions are allowed. One point already satisfies the condition at time 0. Equal journey durations allow different speed magnitudes for different segment lengths. These fixed-target dynamics, common interval and all-point meeting predicate are supplied practice rules.
Function
meetAtSameTime(points: int[][]) → booleanExamples
Example 1
points = [[0,0],[4,2]]return = trueAt t=1/2 both straight-line trajectories are at [2,1], so the result is true.
Example 2
points = [[0,0],[2,0],[0,2]]return = falseThe centroid is [2/3,2/3]. Point 0 remains on y=0 throughout its segment, so all three points cannot meet. The result is false.
Constraints
1 <= points.length <= 200points[i].length == 2-1000000 <= points[i][d] <= 1000000